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