From 892a615c358947fe73e857f02c96d331c56ea515 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 14 Jun 2024 14:06:40 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=E0=B9=83?= =?UTF-8?q?=E0=B8=AB=E0=B9=89=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82?= =?UTF-8?q?=E0=B8=AA=E0=B8=B4=E0=B8=97=E0=B8=98=E0=B8=B4=E0=B9=8C=E0=B9=84?= =?UTF-8?q?=E0=B8=94=E0=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/AuthRoleController.ts | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/controllers/AuthRoleController.ts b/src/controllers/AuthRoleController.ts index 3f222267..175c749e 100644 --- a/src/controllers/AuthRoleController.ts +++ b/src/controllers/AuthRoleController.ts @@ -78,9 +78,18 @@ export class AuthRoleController extends Controller { @Post("govoment") public async AddAuthRoleGovoment(@Request() req: RequestWithUser, @Body() body: CreateAddAuthRole) { - const getDetail = await this.authRoleRepo.findOneBy({ id: body.authRoleId }); - if (!getDetail) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลสิทธิ์"); + let _NULL_ : any = null; + let getDetail + + if(body.authRoleId == "") { + body.authRoleId = _NULL_ + } + else { + getDetail = await this.authRoleRepo.findOneBy({ id: body.authRoleId }); + if (!getDetail) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลสิทธิ์"); + } + const posMaster = await this.posMasterRepository.findOneBy({ id : body.posMasterId }) if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง"); @@ -93,8 +102,18 @@ export class AuthRoleController extends Controller { @Post("employee") public async AddAuthRoleEmployee(@Request() req: RequestWithUser, @Body() body: CreateAddAuthRole) { - const getDetail = await this.authRoleRepo.findOneBy({ id: body.authRoleId }); - if (!getDetail) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลสิทธิ์"); + + let _NULL_ : any = null; + let getDetail + + if(body.authRoleId == "") { + body.authRoleId = _NULL_ + } + else { + getDetail = await this.authRoleRepo.findOneBy({ id: body.authRoleId }); + if (!getDetail) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลสิทธิ์"); + } + const posMaster = await this.employeePosMasterRepository.findOneBy({ id : body.posMasterId }) if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");