forked from Yara724/api
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
UseGuards,
|
|
} from "@nestjs/common";
|
|
import { ApiBearerAuth, ApiTags } from "@nestjs/swagger";
|
|
import { GlobalGuard } from "src/auth/guards/global.guard";
|
|
import { RolesGuard } from "src/auth/guards/role.guard";
|
|
import { Roles } from "src/decorators/roles.decorator";
|
|
import { CurrentUser } from "src/decorators/user.decorator";
|
|
import { RoleEnum } from "src/Types&Enums/role.enum";
|
|
import { ClientService } from "./client.service";
|
|
import { ClientDto } from "./dto/create-client.dto";
|
|
|
|
@Controller("client")
|
|
@ApiTags("client-management")
|
|
@ApiBearerAuth()
|
|
@UseGuards(GlobalGuard, RolesGuard)
|
|
@Roles(RoleEnum.ADMIN)
|
|
export class ClientController {
|
|
constructor(private readonly clientService: ClientService) {}
|
|
|
|
@Post()
|
|
async addClient(@Body() client: ClientDto) {
|
|
return await this.clientService.addClient(client);
|
|
}
|
|
|
|
@Get()
|
|
async getClient(@CurrentUser() user) {
|
|
return await this.clientService.getClients();
|
|
}
|
|
|
|
@Get("list")
|
|
async getClientList(@CurrentUser() user) {
|
|
return await this.clientService.getClientList();
|
|
}
|
|
}
|