72 lines
2.9 KiB
TypeScript
72 lines
2.9 KiB
TypeScript
import { Controller, Post, Body, HttpCode, HttpStatus, Get, UseGuards, Patch, Param, Delete } from '@nestjs/common';
|
|
import { AdminService } from '../providers/admin.service';
|
|
import { UpdateAdminDto } from '../dto/update-admin.dto';
|
|
import { ApiTags, ApiOperation, ApiBody, ApiBearerAuth, ApiParam } from '@nestjs/swagger';
|
|
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
|
|
import { SuperAdminAuthGuard } from 'src/modules/auth/guards/superAdminAuth.guard';
|
|
import { BusinessId } from 'src/common/decorators';
|
|
import { AdminId } from 'src/common/decorators/admin-id.decorator';
|
|
import { Permission } from 'src/common/enums/permission.enum';
|
|
import { Permissions } from 'src/common/decorators/permissions.decorator';
|
|
|
|
@ApiBearerAuth()
|
|
@ApiTags('admin')
|
|
@Controller()
|
|
export class AdminController {
|
|
constructor(private readonly adminService: AdminService) { }
|
|
|
|
// @Get('admin/admins')
|
|
// @UseGuards(AdminAuthGuard)
|
|
// @Permissions(Permission.MANAGE_ADMINS)
|
|
// getAll(@BusinessId() restId: string) {
|
|
// return this.adminService.findAllByRestaurantId(restId);
|
|
// }
|
|
|
|
// @Get('admin/admins/profile')
|
|
// @UseGuards(AdminAuthGuard)
|
|
// @Permissions(Permission.MANAGE_ADMINS)
|
|
// getMe(@AdminId() adminId: string, @BusinessId() restId: string) {
|
|
// return this.adminService.finAdminById(adminId, restId);
|
|
// }
|
|
|
|
|
|
// @Patch('admin/admins/:adminId')
|
|
// @UseGuards(AdminAuthGuard)
|
|
// @Permissions(Permission.MANAGE_ADMINS)
|
|
// @ApiOperation({ summary: 'Update an admin' })
|
|
// @ApiParam({ name: 'adminId', description: 'Admin ID' })
|
|
// update(@Param('adminId') adminId: string, @Body() dto: UpdateAdminDto,
|
|
// @BusinessId() restId: string) {
|
|
// return this.adminService.update(adminId, restId, dto);
|
|
// }
|
|
|
|
// @Get('admin/admins/:adminId')
|
|
// @UseGuards(AdminAuthGuard)
|
|
// @Permissions(Permission.MANAGE_ADMINS)
|
|
// getById(@Param('adminId') adminId: string, @BusinessId() restId: string) {
|
|
// return this.adminService.finAdminById(adminId, restId);
|
|
// }
|
|
|
|
// @Delete('admin/admins/:adminId')
|
|
// @UseGuards(AdminAuthGuard)
|
|
// @Permissions(Permission.MANAGE_ADMINS)
|
|
// @ApiOperation({ summary: 'Delete an admin by ID' })
|
|
// @ApiParam({ name: 'id', description: 'Admin ID' })
|
|
// deleteById(@Param('adminId') adminId: string, @BusinessId() restId: string) {
|
|
// return this.adminService.remove(adminId, restId);
|
|
// }
|
|
|
|
|
|
// @UseGuards(SuperAdminAuthGuard)
|
|
// @Delete('super-admin/restaurants/:restaurantId/admins/:adminId')
|
|
// @ApiOperation({ summary: 'Revoke admin role from a restaurant (Super Admin only)' })
|
|
// @ApiParam({ name: 'restaurantId', description: 'Restaurant ID' })
|
|
// @ApiParam({ name: 'adminId', description: 'Admin ID' })
|
|
// revokeAdminFromRestaurant(
|
|
// @Param('restaurantId') restaurantId: string,
|
|
// @Param('adminId') adminId: string,
|
|
// ) {
|
|
// return this.adminService.remove(adminId, restaurantId);
|
|
// }
|
|
}
|