packages/server/src/modules/user/user.controller.ts
Methods |
Async all | ||||||
all(query: UserQuery)
|
||||||
Decorators :
@Get('/')
|
||||||
Parameters :
Returns :
unknown
|
Async changePassword | |||||||||
changePassword(body: UserPasswordRequest, user: ActiveUserData)
|
|||||||||
Decorators :
@Put('/:id/password')
|
|||||||||
Parameters :
Returns :
unknown
|
Async create | ||||||
create(body: UserRequest)
|
||||||
Decorators :
@Post('/')
|
||||||
Parameters :
Returns :
unknown
|
Async one | ||||||
one(id: number)
|
||||||
Decorators :
@Get('/:id')
|
||||||
Parameters :
Returns :
unknown
|
Async remote | ||||||
remote(id: number)
|
||||||
Decorators :
@Delete('/:id')
|
||||||
Parameters :
Returns :
unknown
|
Async update | |||||||||
update(id: number, body: UserRequest)
|
|||||||||
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 { ActiveUser } from "@/common/decorators/active-user.decorator";
import { Roles } from "@/common/decorators/roles.decorator";
import { ActiveUserData } from "@/common/interfaces/active-user-data.interface";
import { Log4jsService } from "@/modules/log4js";
import { UserPasswordRequest, UserQuery, UserRequest } from "./user.interface";
import { UserService } from "./user.service";
@Controller({
path: ["users"],
})
@Roles(Role.Admin)
export class UserController {
constructor(
private userService: UserService,
private readonly log4jService: Log4jsService
) {}
@Get("/")
async all(@Query() query: UserQuery) {
return this.userService.all(query);
}
@Get("/:id")
async one(@Param("id") id: number) {
return this.userService.getById(id);
}
@Post("/")
async create(@Body() body: UserRequest) {
return this.userService.create(body);
}
@Put("/:id")
async update(@Param("id") id: number, @Body() body: UserRequest) {
return this.userService.update(id, body);
}
@Put("/:id/password")
async changePassword(
@Body() body: UserPasswordRequest,
@ActiveUser() user: ActiveUserData
) {
return this.userService.changePassword(body, user);
}
@Delete("/:id")
async remote(@Param("id") id: number) {
return this.userService.remove(id);
}
}