ดักกรณีลบผังลูกจ้าง
This commit is contained in:
parent
b27c61a01f
commit
ffcf3b1b73
1 changed files with 13 additions and 0 deletions
|
|
@ -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 },
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue