API ลบผังเงินเดือน

This commit is contained in:
Bright 2024-02-15 17:48:57 +07:00
parent bf8f0c207d
commit f6b1ac9d1c

View file

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