mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 07:34:54 +00:00
43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Get,
|
|
HttpStatus,
|
|
Post,
|
|
UseGuards,
|
|
} from '@nestjs/common';
|
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
|
import { RoleService } from '../services/role.service';
|
|
import { AddUserRoleDto } from '../dtos';
|
|
import { SuperAdminRoleGuard } from 'src/guards/super.admin.role.guard';
|
|
|
|
@ApiTags('Role Module')
|
|
@Controller({
|
|
version: '1',
|
|
path: 'role',
|
|
})
|
|
export class RoleController {
|
|
constructor(private readonly roleService: RoleService) {}
|
|
@ApiBearerAuth()
|
|
@UseGuards(SuperAdminRoleGuard)
|
|
@Get('types')
|
|
async fetchRoleTypes() {
|
|
const roleTypes = await this.roleService.fetchRoleTypes();
|
|
return {
|
|
statusCode: HttpStatus.OK,
|
|
message: 'Role Types fetched Successfully',
|
|
data: roleTypes,
|
|
};
|
|
}
|
|
@ApiBearerAuth()
|
|
@UseGuards(SuperAdminRoleGuard)
|
|
@Post()
|
|
async addUserRoleType(@Body() addUserRoleDto: AddUserRoleDto) {
|
|
await this.roleService.addUserRoleType(addUserRoleDto);
|
|
return {
|
|
statusCode: HttpStatus.OK,
|
|
message: 'User Role Added Successfully',
|
|
};
|
|
}
|
|
}
|