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; + } + } + }