Initial commit: ERP system with advance verification fixes
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import { Controller, Get, Post, Put, Delete, Body, Param, UseGuards } from '@nestjs/common';
|
||||
import { RolesService } from './roles.service';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
|
||||
@Controller('api/v1/roles')
|
||||
export class RolesController {
|
||||
constructor(private readonly rolesService: RolesService) {}
|
||||
|
||||
@Post()
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async create(
|
||||
@Body('name') name: string,
|
||||
@Body('description') description: string,
|
||||
@Body('permissionIds') permissionIds: string[],
|
||||
) {
|
||||
return this.rolesService.create(name, description, permissionIds);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async findAll() {
|
||||
return this.rolesService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async findById(@Param('id') id: string) {
|
||||
return this.rolesService.findById(id);
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async update(
|
||||
@Param('id') id: string,
|
||||
@Body('name') name: string,
|
||||
@Body('description') description: string,
|
||||
@Body('permissionIds') permissionIds: string[],
|
||||
) {
|
||||
return this.rolesService.update(id, name, description, permissionIds);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async delete(@Param('id') id: string) {
|
||||
return this.rolesService.delete(id);
|
||||
}
|
||||
|
||||
@Post(':id/permissions')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async assignPermissions(
|
||||
@Param('id') roleId: string,
|
||||
@Body('permissionIds') permissionIds: string[],
|
||||
) {
|
||||
return this.rolesService.assignPermissions(roleId, permissionIds);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user