File

packages/server/src/modules/role/role.controller.ts

Index

Methods

Methods

Async all
all(query: RoleQuery)
Decorators :
@Get('/')
Parameters :
Name Type Optional
query RoleQuery No
Returns : unknown
Async create
create(body: RoleRequest)
Decorators :
@Post('/')
Parameters :
Name Type Optional
body RoleRequest No
Returns : unknown
Async one
one(id: number)
Decorators :
@Get('/:id')
Parameters :
Name Type Optional
id number No
Returns : unknown
Async oneAndMenus
oneAndMenus(id: number)
Decorators :
@Get('/:id/permission')
Parameters :
Name Type Optional
id number No
Returns : unknown
Async remote
remote(id: number)
Decorators :
@Delete('/:id')
Parameters :
Name Type Optional
id number No
Returns : unknown
Async update
update(id: number, body: RoleRequest)
Decorators :
@Put('/:id')
Parameters :
Name Type Optional
id number No
body RoleRequest No
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);
  }
}

results matching ""

    No results matching ""