set role perms
This commit is contained in:
@@ -11,8 +11,10 @@ import { Permission } from 'src/common/enums/permission.enum';
|
||||
|
||||
|
||||
|
||||
@ApiTags('roles')
|
||||
@Controller()
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiTags('roles')
|
||||
export class RolesController {
|
||||
constructor(
|
||||
private readonly roleService: RolesService,
|
||||
@@ -20,50 +22,35 @@ export class RolesController {
|
||||
) { }
|
||||
|
||||
@Post('admin/role')
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ROLES)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Create a new role' })
|
||||
@ApiBody({ type: CreateRoleDto })
|
||||
create(@Body() dto: CreateRoleDto,) {
|
||||
return this.roleService.create(dto);
|
||||
}
|
||||
|
||||
@Get('admin/roles')
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ROLES)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Get all through restaurant roles with pagination and filters' })
|
||||
findAll() {
|
||||
return this.roleService.findAll();
|
||||
}
|
||||
|
||||
@Get('admin/roles/permissions')
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ROLES)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Get all permissions that the admin has' })
|
||||
async findAllPermissions(@AdminId() adminId: string,) {
|
||||
const adminPermissionNames = await this.permissionService.getAdminPermissions(adminId);
|
||||
|
||||
return adminPermissionNames;
|
||||
return this.permissionService.getAdminPermissions(adminId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Get('admin/roles/:id')
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ROLES)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Get a specific role by ID' })
|
||||
findOne(@Param('id') id: string,) {
|
||||
return this.roleService.findOne( id);
|
||||
return this.roleService.findOne(id);
|
||||
}
|
||||
|
||||
@Patch('admin/roles/:id')
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ROLES)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Update a role' })
|
||||
@ApiBody({ type: UpdateRoleDto })
|
||||
update(@Param('id') id: string, @Body() dto: UpdateRoleDto,) {
|
||||
@@ -71,13 +58,10 @@ export class RolesController {
|
||||
}
|
||||
|
||||
@Delete('admin/roles/:id')
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ROLES)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Delete a role' })
|
||||
remove(@Param('id') id: string,) {
|
||||
return this.roleService.remove( id);
|
||||
return this.roleService.remove(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user