เพิ่มเงื่อนไข posTypeRank
This commit is contained in:
parent
85ba718bbd
commit
e4248c09f8
1 changed files with 24 additions and 4 deletions
|
|
@ -38,7 +38,6 @@ export class EmployeePosTypeController extends Controller {
|
||||||
private employeePosDictRepository = AppDataSource.getRepository(EmployeePosDict);
|
private employeePosDictRepository = AppDataSource.getRepository(EmployeePosDict);
|
||||||
private employeePosTypeRepository = AppDataSource.getRepository(EmployeePosType);
|
private employeePosTypeRepository = AppDataSource.getRepository(EmployeePosType);
|
||||||
private employeePosLevelRepository = AppDataSource.getRepository(EmployeePosLevel);
|
private employeePosLevelRepository = AppDataSource.getRepository(EmployeePosLevel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API เพิ่มกลุ่มงานลูกจ้างประจำ
|
* API เพิ่มกลุ่มงานลูกจ้างประจำ
|
||||||
*
|
*
|
||||||
|
|
@ -52,9 +51,6 @@ export class EmployeePosTypeController extends Controller {
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: { user: Record<string, any> },
|
||||||
) {
|
) {
|
||||||
const EmpPosType = Object.assign(new EmployeePosType(), requestBody);
|
const EmpPosType = Object.assign(new EmployeePosType(), requestBody);
|
||||||
if (!EmpPosType) {
|
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
||||||
}
|
|
||||||
|
|
||||||
const chkEmpPosTypeName = await this.employeePosTypeRepository.findOne({
|
const chkEmpPosTypeName = await this.employeePosTypeRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -64,6 +60,18 @@ export class EmployeePosTypeController extends Controller {
|
||||||
if (chkEmpPosTypeName) {
|
if (chkEmpPosTypeName) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const posTypeRank = await this.employeePosTypeRepository.findOne({
|
||||||
|
where: {
|
||||||
|
posTypeRank: requestBody.posTypeRank,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (posTypeRank) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ระดับของกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว",
|
||||||
|
);
|
||||||
|
}
|
||||||
EmpPosType.createdUserId = request.user.sub;
|
EmpPosType.createdUserId = request.user.sub;
|
||||||
EmpPosType.createdFullName = request.user.name;
|
EmpPosType.createdFullName = request.user.name;
|
||||||
EmpPosType.lastUpdateUserId = request.user.sub;
|
EmpPosType.lastUpdateUserId = request.user.sub;
|
||||||
|
|
@ -98,6 +106,18 @@ export class EmployeePosTypeController extends Controller {
|
||||||
if (chkEmpPosType) {
|
if (chkEmpPosType) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว");
|
||||||
}
|
}
|
||||||
|
const posTypeRank = await this.employeePosTypeRepository.findOne({
|
||||||
|
where: {
|
||||||
|
id: Not(id),
|
||||||
|
posTypeRank: requestBody.posTypeRank,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (posTypeRank) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ระดับของกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว",
|
||||||
|
);
|
||||||
|
}
|
||||||
EmpPosType.lastUpdateUserId = request.user.sub;
|
EmpPosType.lastUpdateUserId = request.user.sub;
|
||||||
EmpPosType.lastUpdateFullName = request.user.name;
|
EmpPosType.lastUpdateFullName = request.user.name;
|
||||||
this.employeePosTypeRepository.merge(EmpPosType, requestBody);
|
this.employeePosTypeRepository.merge(EmpPosType, requestBody);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue