From 5f222498cbe81950b0cdbcf3f0f9d67a539ca5dc Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 27 Feb 2024 17:14:22 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=20SLR=5F018=20,=20?= =?UTF-8?q?=E0=B8=A5=E0=B8=9A=20return=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/PosLevelController.ts | 6 +++--- src/controllers/PosTypeController.ts | 6 +++--- src/controllers/ReportController.ts | 2 +- src/controllers/SalaryController.ts | 7 +++---- src/controllers/SalaryPeriodController.ts | 12 +++++++++--- src/controllers/SalaryRankController.ts | 4 ++-- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/controllers/PosLevelController.ts b/src/controllers/PosLevelController.ts index 3f4395b..1f51b5a 100644 --- a/src/controllers/PosLevelController.ts +++ b/src/controllers/PosLevelController.ts @@ -122,7 +122,7 @@ export class PosLevelController extends Controller { ) { const posLevel = await this.posLevelRepository.findOne({ where: { id } }); if (!posLevel) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้"); } const chkPosTypeId = await this.posTypeRepository.findOne({ @@ -180,7 +180,7 @@ export class PosLevelController extends Controller { async deleteLevel(@Path() id: string) { const delPosLevel = await this.posLevelRepository.findOne({ where: { id } }); if (!delPosLevel) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้"); } // try { await this.posLevelRepository.remove(delPosLevel); @@ -217,7 +217,7 @@ export class PosLevelController extends Controller { where: { id: id }, }); if (!getPosType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้"); } const mapPosLevel = { diff --git a/src/controllers/PosTypeController.ts b/src/controllers/PosTypeController.ts index da2d373..72ce810 100644 --- a/src/controllers/PosTypeController.ts +++ b/src/controllers/PosTypeController.ts @@ -98,7 +98,7 @@ export class PosTypeController extends Controller { ) { const posType = await this.posTypeRepository.findOne({ where: { id } }); if (!posType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้"); } const chkPosTypeName = await this.posTypeRepository.findOne({ where: { @@ -134,7 +134,7 @@ export class PosTypeController extends Controller { async deleteType(@Path() id: string) { const delPosType = await this.posTypeRepository.findOne({ where: { id } }); if (!delPosType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้"); } const IdExitsInLevel = await this.posLevelRepository.find({ where: { posTypeId: id }, @@ -182,7 +182,7 @@ export class PosTypeController extends Controller { where: { id: id }, }); if (!getPosType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้"); } const mapGetPosType = { diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index b9f7cf0..5646cac 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -53,7 +53,7 @@ export class ReportController extends Controller { where: { id: id } }); if (!salarys) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี: " + id); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี"); } const posType = await this.poTypeRepository.findOne({ where: { id: salarys.posTypeId }, diff --git a/src/controllers/SalaryController.ts b/src/controllers/SalaryController.ts index 9d154a9..237d605 100644 --- a/src/controllers/SalaryController.ts +++ b/src/controllers/SalaryController.ts @@ -132,7 +132,7 @@ export class Salary extends Controller { where: { id: id }, }); if (!chk_Salary) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี: " + id); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี"); } if (chk_Salary.isActive && !requestBody.isActive) { @@ -205,12 +205,11 @@ export class Salary extends Controller { where: { id: id }, }); if (!chk_Salary) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี: " + id); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี"); } if (chk_Salary.isActive) { throw new HttpError( HttpStatusCode.NOT_FOUND, - // "ไม่สามารถลบไอดี: " + id + " ได้ เนื่องสถานะการใช้งานที่เป็น Default", "ไม่สามารถลบข้อมูลนี้ได้ เนื่องจากเปิดใช้งานอยู่", ); } @@ -260,7 +259,7 @@ export class Salary extends Controller { ], }); if (!salary) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี: " + id); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี"); } return new HttpSuccess(salary); // } catch (error: any) { diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index 8d22881..f39afd8 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -516,7 +516,7 @@ export class SalaryPeriodController extends Controller { where: { id: id }, }); if (!chk_SalaryPeriod) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี: " + id); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี"); } const chk_toUpper = ["SPECIAL", "APR", "OCT"]; @@ -560,7 +560,13 @@ export class SalaryPeriodController extends Controller { where: { id: id }, }); if (!SalaryPeriod) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี: " + id); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี"); + } + const SalaryOrg = await this.salaryOrgRepository.findOne({ + where: { salaryPeriodId: SalaryPeriod.id } + }) + if(SalaryOrg){ + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้"); } await this.salaryPeriodRepository.remove(SalaryPeriod); return new HttpSuccess(); @@ -580,7 +586,7 @@ export class SalaryPeriodController extends Controller { select: ["id", "period", "isActive", "effectiveDate", "isActive", "status", "year"], }); if (!salaryPeriod) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี: " + id); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี"); } return new HttpSuccess(salaryPeriod); } diff --git a/src/controllers/SalaryRankController.ts b/src/controllers/SalaryRankController.ts index 6fe0e39..eb878db 100644 --- a/src/controllers/SalaryRankController.ts +++ b/src/controllers/SalaryRankController.ts @@ -84,7 +84,7 @@ export class SalaryRanksController extends Controller { // try { const salaryRank = await this.salaryRankRepository.findOne({ where: { id: id } }); if (!salaryRank) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้"); } salaryRank.lastUpdateUserId = request.user.sub; salaryRank.lastUpdateFullName = request.user.name; @@ -110,7 +110,7 @@ export class SalaryRanksController extends Controller { where: { id }, }); if (!delSalaryRanks) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งตามไอดีนี้ : " + id); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งตามไอดีนี้"); } await this.salaryRankRepository.delete({ id: id }); return new HttpSuccess();