From ffcf3b1b73761946ac3ac9f3e8c63dd4600b3315 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 29 May 2024 09:40:02 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=94=E0=B8=B1=E0=B8=81=E0=B8=81=E0=B8=A3?= =?UTF-8?q?=E0=B8=93=E0=B8=B5=E0=B8=A5=E0=B8=9A=E0=B8=9C=E0=B8=B1=E0=B8=87?= =?UTF-8?q?=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/SalaryEmployeeController.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/controllers/SalaryEmployeeController.ts b/src/controllers/SalaryEmployeeController.ts index 224177f..71e6bd6 100644 --- a/src/controllers/SalaryEmployeeController.ts +++ b/src/controllers/SalaryEmployeeController.ts @@ -26,6 +26,7 @@ import HttpStatusCode from "../interfaces/http-status"; import { SalaryRankEmployee } from "../entities/SalaryRankEmployee"; import { randomUUID } from "crypto"; import { Salarys } from "../entities/Salarys"; +import { SalaryFormulaEmployee } from "../entities/SalaryFormulaEmployee"; @Route("api/v1/salary/employee") @Tags("SalaryEmployee") @@ -33,6 +34,8 @@ import { Salarys } from "../entities/Salarys"; export class SalaryEmployeeController extends Controller { private salaryEmployeeRepository = AppDataSource.getRepository(SalaryEmployee); private salaryRankEmployeeRepository = AppDataSource.getRepository(SalaryRankEmployee); + private salaryFormulaEmployeeRepository = AppDataSource.getRepository(SalaryFormulaEmployee); + /** * API รายการผังเงินเดือนลูกจ้าง(Active) * @@ -171,6 +174,16 @@ export class SalaryEmployeeController extends Controller { "ไม่สามารถลบข้อมูลนี้ได้ เนื่องจากเปิดใช้งานอยู่", ); } + + const chk_SalaryFormulaEmp = await this.salaryFormulaEmployeeRepository.find({ + where: { salaryEmployeeId: id }, + }); + if(chk_SalaryFormulaEmp.length > 0){ + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่สามารถลบรายการนี้ได้เนื่องจากมีการใช้งานอยู่", + ); + } const del_SalaryRank = await this.salaryRankEmployeeRepository.find({ where: { salaryEmployeeId: chk_Salary.id }, });