From f6b1ac9d1c6097918f35e2c5bae85063d0102c3f Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 15 Feb 2024 17:48:57 +0700 Subject: [PATCH] =?UTF-8?q?API=20=E0=B8=A5=E0=B8=9A=E0=B8=9C=E0=B8=B1?= =?UTF-8?q?=E0=B8=87=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80=E0=B8=94?= =?UTF-8?q?=E0=B8=B7=E0=B8=AD=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/SalaryController.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/controllers/SalaryController.ts b/src/controllers/SalaryController.ts index 26c4001..9c72317 100644 --- a/src/controllers/SalaryController.ts +++ b/src/controllers/SalaryController.ts @@ -188,6 +188,33 @@ export class Salary extends Controller { } } + /** + * API ลบผังเงินเดือน + * + * @summary SLR_003 - ลบผังเงินเดือน #3 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Delete("{id}") + async delete_salary(@Path() id: string) { + const chk_Salary = await this.salaryRepository.findOne({ + where: { id: id }, + }); + if (!chk_Salary) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี: "+ id); + } + if (chk_Salary.isActive) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบไอดี: " + id + " ได้ เนื่องสถานะการใช้งานที่เป็น Default"); + } + + try { + await this.salaryRepository.remove(chk_Salary); + return new HttpSuccess(); + } catch (error) { + return error; + } + } + }