57 lines
2.3 KiB
TypeScript
57 lines
2.3 KiB
TypeScript
import {
|
|
Body, Controller, Delete, Get, Param, Post,
|
|
Query, UseInterceptors
|
|
} from "@nestjs/common";
|
|
import { ApiHeader, ApiOperation } from "@nestjs/swagger";
|
|
|
|
import { BarnameService } from "./barname.service";
|
|
import { BillListQueryDto } from "./dto/bill-list-query.dto";
|
|
import { CreateBarnameDto } from "./dto/create-barname.dto";
|
|
import { AuthGuards } from "../../common/decorators/auth-guard.decorator";
|
|
import { BusinessDec } from "../../common/decorators/business.decorator";
|
|
import { ParamDto } from "../../common/DTO/param.dto";
|
|
import { BusinessInterceptor } from "../../core/interceptors/business.interceptor";
|
|
import { Business } from "../businesses/entities/business.entity";
|
|
import { UserDec } from "../../common/decorators/user.decorator";
|
|
import { RoleEnum } from "../users/enums/role.enum";
|
|
import { UpdateBarnameAsWatcherDto } from "./dto/update-barname-watcher.dto";
|
|
|
|
@Controller("barname")
|
|
@UseInterceptors(BusinessInterceptor)
|
|
@AuthGuards()
|
|
export class BarnameController {
|
|
constructor(private readonly billsService: BarnameService) { }
|
|
|
|
@ApiOperation({ summary: "Create barname" })
|
|
@Post()
|
|
@ApiHeader({ name: "x-business-id" })
|
|
createWaterBill(@Body() dto: CreateBarnameDto, @BusinessDec() business: Business, @UserDec("id") userId: string,) {
|
|
return this.billsService.createBarname(dto, business, userId);
|
|
}
|
|
|
|
@ApiOperation({ summary: "Get all barname with filters and pagination" })
|
|
@Get()
|
|
@ApiHeader({ name: "x-business-id" })
|
|
findAll(@Query() dto: BillListQueryDto, @BusinessDec("id") businessId: string) {
|
|
return this.billsService.findAll(dto, businessId);
|
|
}
|
|
|
|
@ApiOperation({ summary: "Get a barname by id" })
|
|
@Get(":id")
|
|
findOne(@Param() paramDto: ParamDto, @BusinessDec("id") businessId: string) {
|
|
return this.billsService.findOne(paramDto.id, businessId);
|
|
}
|
|
|
|
@ApiOperation({ summary: "Update Barname by watcher" })
|
|
@Get(":id/watcher")
|
|
update(@Param('id') id: string, @BusinessDec() business: Business, @Body() dto: UpdateBarnameAsWatcherDto, @UserDec("role") role: RoleEnum) {
|
|
return this.billsService.updateBarnameAsWatcher(id, dto, business, role);
|
|
}
|
|
|
|
@ApiOperation({ summary: "Remove a barname" })
|
|
@Delete(":id")
|
|
remove(@Param() paramDto: ParamDto, @BusinessDec("id") businessId: string) {
|
|
return this.billsService.remove(paramDto.id, businessId);
|
|
}
|
|
}
|