Files
backend/src/role/controllers/role.controller.ts

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',
};
}
}