packages/server/src/modules/role/role.controller.ts
Methods |
Async all | ||||||
all(query: RoleQuery)
|
||||||
Decorators :
@Get('/')
|
||||||
Parameters :
Returns :
unknown
|
Async create | ||||||
create(body: RoleRequest)
|
||||||
Decorators :
@Post('/')
|
||||||
Parameters :
Returns :
unknown
|
Async one | ||||||
one(id: number)
|
||||||
Decorators :
@Get('/:id')
|
||||||
Parameters :
Returns :
unknown
|
Async oneAndMenus | ||||||
oneAndMenus(id: number)
|
||||||
Decorators :
@Get('/:id/permission')
|
||||||
Parameters :
Returns :
unknown
|
Async remote | ||||||
remote(id: number)
|
||||||
Decorators :
@Delete('/:id')
|
||||||
Parameters :
Returns :
unknown
|
Async update | |||||||||
update(id: number, body: RoleRequest)
|
|||||||||
Decorators :
@Put('/:id')
|
|||||||||
Parameters :
Returns :
unknown
|
import { Role } from "@bill/database";
import {
Controller,
Request,
Get,
Post,
Body,
Param,
Put,
Delete,
Query,
} from "@nestjs/common";
import { Public } from "@/common/decorators/public.decorator";
import { Roles } from "@/common/decorators/roles.decorator";
import { Log4jsService } from "@/modules/log4js";
import { RoleQuery, RoleRequest } from "./role.interface";
import { RoleService } from "./role.service";
@Controller({
path: ["roles"],
})
@Roles(Role.Admin)
export class RoleController {
constructor(
private roleService: RoleService,
private readonly log4jService: Log4jsService
) {}
@Get("/")
async all(@Query() query: RoleQuery) {
return this.roleService.all(query);
}
@Get("/:id")
async one(@Param("id") id: number) {
return this.roleService.getById(id);
}
@Get("/:id/permission")
async oneAndMenus(@Param("id") id: number) {
return this.roleService.getByIdWithPermission(id);
}
@Post("/")
async create(@Body() body: RoleRequest) {
return this.roleService.create(body);
}
@Put("/:id")
async update(@Param("id") id: number, @Body() body: RoleRequest) {
return this.roleService.update(id, body);
}
@Delete("/:id")
async remote(@Param("id") id: number) {
return this.roleService.remove(id);
}
}