mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 22:14:55 +00:00
Update RoleController to use static route constants and add API operation descriptions
This commit is contained in:
@ -6,22 +6,28 @@ import {
|
||||
Post,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { RoleService } from '../services/role.service';
|
||||
import { AddUserRoleDto } from '../dtos';
|
||||
import { SuperAdminRoleGuard } from 'src/guards/super.admin.role.guard';
|
||||
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
|
||||
import { ControllerRoute } from '@app/common/constants/controller-route'; // Assuming this is where the routes are defined
|
||||
|
||||
@ApiTags('Role Module')
|
||||
@Controller({
|
||||
version: EnableDisableStatusEnum.ENABLED,
|
||||
path: 'role',
|
||||
path: ControllerRoute.ROLE.ROUTE, // use the static route constant
|
||||
})
|
||||
export class RoleController {
|
||||
constructor(private readonly roleService: RoleService) {}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(SuperAdminRoleGuard)
|
||||
@Get('types')
|
||||
@ApiOperation({
|
||||
summary: ControllerRoute.ROLE.ACTIONS.FETCH_ROLE_TYPES_SUMMARY,
|
||||
description: ControllerRoute.ROLE.ACTIONS.FETCH_ROLE_TYPES_DESCRIPTION,
|
||||
})
|
||||
async fetchRoleTypes() {
|
||||
const roleTypes = await this.roleService.fetchRoleTypes();
|
||||
return {
|
||||
@ -30,9 +36,14 @@ export class RoleController {
|
||||
data: roleTypes,
|
||||
};
|
||||
}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(SuperAdminRoleGuard)
|
||||
@Post()
|
||||
@ApiOperation({
|
||||
summary: ControllerRoute.ROLE.ACTIONS.ADD_USER_ROLE_SUMMARY,
|
||||
description: ControllerRoute.ROLE.ACTIONS.ADD_USER_ROLE_DESCRIPTION,
|
||||
})
|
||||
async addUserRoleType(@Body() addUserRoleDto: AddUserRoleDto) {
|
||||
await this.roleService.addUserRoleType(addUserRoleDto);
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user