mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 13:54:53 +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,
|
Post,
|
||||||
UseGuards,
|
UseGuards,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||||
import { RoleService } from '../services/role.service';
|
import { RoleService } from '../services/role.service';
|
||||||
import { AddUserRoleDto } from '../dtos';
|
import { AddUserRoleDto } from '../dtos';
|
||||||
import { SuperAdminRoleGuard } from 'src/guards/super.admin.role.guard';
|
import { SuperAdminRoleGuard } from 'src/guards/super.admin.role.guard';
|
||||||
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
|
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')
|
@ApiTags('Role Module')
|
||||||
@Controller({
|
@Controller({
|
||||||
version: EnableDisableStatusEnum.ENABLED,
|
version: EnableDisableStatusEnum.ENABLED,
|
||||||
path: 'role',
|
path: ControllerRoute.ROLE.ROUTE, // use the static route constant
|
||||||
})
|
})
|
||||||
export class RoleController {
|
export class RoleController {
|
||||||
constructor(private readonly roleService: RoleService) {}
|
constructor(private readonly roleService: RoleService) {}
|
||||||
|
|
||||||
@ApiBearerAuth()
|
@ApiBearerAuth()
|
||||||
@UseGuards(SuperAdminRoleGuard)
|
@UseGuards(SuperAdminRoleGuard)
|
||||||
@Get('types')
|
@Get('types')
|
||||||
|
@ApiOperation({
|
||||||
|
summary: ControllerRoute.ROLE.ACTIONS.FETCH_ROLE_TYPES_SUMMARY,
|
||||||
|
description: ControllerRoute.ROLE.ACTIONS.FETCH_ROLE_TYPES_DESCRIPTION,
|
||||||
|
})
|
||||||
async fetchRoleTypes() {
|
async fetchRoleTypes() {
|
||||||
const roleTypes = await this.roleService.fetchRoleTypes();
|
const roleTypes = await this.roleService.fetchRoleTypes();
|
||||||
return {
|
return {
|
||||||
@ -30,9 +36,14 @@ export class RoleController {
|
|||||||
data: roleTypes,
|
data: roleTypes,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiBearerAuth()
|
@ApiBearerAuth()
|
||||||
@UseGuards(SuperAdminRoleGuard)
|
@UseGuards(SuperAdminRoleGuard)
|
||||||
@Post()
|
@Post()
|
||||||
|
@ApiOperation({
|
||||||
|
summary: ControllerRoute.ROLE.ACTIONS.ADD_USER_ROLE_SUMMARY,
|
||||||
|
description: ControllerRoute.ROLE.ACTIONS.ADD_USER_ROLE_DESCRIPTION,
|
||||||
|
})
|
||||||
async addUserRoleType(@Body() addUserRoleDto: AddUserRoleDto) {
|
async addUserRoleType(@Body() addUserRoleDto: AddUserRoleDto) {
|
||||||
await this.roleService.addUserRoleType(addUserRoleDto);
|
await this.roleService.addUserRoleType(addUserRoleDto);
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user