barname
This commit is contained in:
@@ -13,6 +13,8 @@ import { ParamDto } from "../../common/DTO/param.dto";
|
|||||||
import { BusinessInterceptor } from "../../core/interceptors/business.interceptor";
|
import { BusinessInterceptor } from "../../core/interceptors/business.interceptor";
|
||||||
import { Business } from "../businesses/entities/business.entity";
|
import { Business } from "../businesses/entities/business.entity";
|
||||||
import { UserDec } from "../../common/decorators/user.decorator";
|
import { UserDec } from "../../common/decorators/user.decorator";
|
||||||
|
import { RoleEnum } from "../users/enums/role.enum";
|
||||||
|
import { UpdateBarnameAsWatcherDto } from "./dto/update-barname-watcher.dto";
|
||||||
|
|
||||||
@Controller("barname")
|
@Controller("barname")
|
||||||
@UseInterceptors(BusinessInterceptor)
|
@UseInterceptors(BusinessInterceptor)
|
||||||
@@ -42,8 +44,8 @@ export class BarnameController {
|
|||||||
|
|
||||||
@ApiOperation({ summary: "Update Barname by watcher" })
|
@ApiOperation({ summary: "Update Barname by watcher" })
|
||||||
@Get(":id/watcher")
|
@Get(":id/watcher")
|
||||||
update(@Param() dto: ParamDto, @BusinessDec("id") businessId: string) {
|
update(@Param('id') id: string, @BusinessDec() business: Business, @Body() dto: UpdateBarnameAsWatcherDto, @UserDec("role") role: RoleEnum) {
|
||||||
return this.billsService.findOne(dto.id, businessId);
|
return this.billsService.updateBarnameAsWatcher(id, dto, business, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation({ summary: "Remove a barname" })
|
@ApiOperation({ summary: "Remove a barname" })
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { EntityManager } from "@mikro-orm/postgresql";
|
import { EntityManager } from "@mikro-orm/postgresql";
|
||||||
import { BadRequestException, Injectable } from "@nestjs/common";
|
import { BadRequestException, ForbiddenException, Injectable } from "@nestjs/common";
|
||||||
|
|
||||||
import { BillListQueryDto } from "./dto/bill-list-query.dto";
|
import { BillListQueryDto } from "./dto/bill-list-query.dto";
|
||||||
import { CreateBarnameDto } from "./dto/create-barname.dto";
|
import { CreateBarnameDto } from "./dto/create-barname.dto";
|
||||||
@@ -10,6 +10,7 @@ import { Business } from "../businesses/entities/business.entity";
|
|||||||
import { Company } from "../companies/entities/company.entity";
|
import { Company } from "../companies/entities/company.entity";
|
||||||
import { BarnameStatus } from "./enums/bill-type.enum";
|
import { BarnameStatus } from "./enums/bill-type.enum";
|
||||||
import { UpdateBarnameAsWatcherDto } from "./dto/update-barname-watcher.dto";
|
import { UpdateBarnameAsWatcherDto } from "./dto/update-barname-watcher.dto";
|
||||||
|
import { RoleEnum } from "../users/enums/role.enum";
|
||||||
// import { CompaniesService } from "../companies/services/companies.service";
|
// import { CompaniesService } from "../companies/services/companies.service";
|
||||||
|
|
||||||
|
|
||||||
@@ -38,13 +39,15 @@ export class BarnameService {
|
|||||||
return bill
|
return bill
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateBarname(id: string, dto: UpdateBarnameAsWatcherDto, business: Business, userId: string) {
|
async updateBarnameAsWatcher(id: string, dto: UpdateBarnameAsWatcherDto, business: Business, role: RoleEnum) {
|
||||||
|
|
||||||
|
if(role != RoleEnum.WATCHER){
|
||||||
|
throw new ForbiddenException("you are not allowed")
|
||||||
|
}
|
||||||
const { exitedAt, watcherDescription } = dto;
|
const { exitedAt, watcherDescription } = dto;
|
||||||
|
|
||||||
const barname = await this.findOne(id, business.id)
|
const barname = await this.findOne(id, business.id)
|
||||||
|
|
||||||
console.log(userId)
|
|
||||||
|
|
||||||
if (exitedAt) {
|
if (exitedAt) {
|
||||||
barname.exitedAt = exitedAt
|
barname.exitedAt = exitedAt
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export enum RoleEnum {
|
export enum RoleEnum {
|
||||||
ADMIN = "ADMIN",
|
ADMIN = "ADMIN",
|
||||||
USER = "USER",
|
USER = "USER",
|
||||||
|
WATCHER = "WATCHER",
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user