Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
This commit is contained in:
commit
ce7f814061
1 changed files with 24 additions and 4 deletions
|
|
@ -38,7 +38,6 @@ export class EmployeePosTypeController extends Controller {
|
|||
private employeePosDictRepository = AppDataSource.getRepository(EmployeePosDict);
|
||||
private employeePosTypeRepository = AppDataSource.getRepository(EmployeePosType);
|
||||
private employeePosLevelRepository = AppDataSource.getRepository(EmployeePosLevel);
|
||||
|
||||
/**
|
||||
* API เพิ่มกลุ่มงานลูกจ้างประจำ
|
||||
*
|
||||
|
|
@ -52,9 +51,6 @@ export class EmployeePosTypeController extends Controller {
|
|||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
const EmpPosType = Object.assign(new EmployeePosType(), requestBody);
|
||||
if (!EmpPosType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const chkEmpPosTypeName = await this.employeePosTypeRepository.findOne({
|
||||
where: {
|
||||
|
|
@ -64,6 +60,18 @@ export class EmployeePosTypeController extends Controller {
|
|||
if (chkEmpPosTypeName) {
|
||||
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.createdFullName = request.user.name;
|
||||
EmpPosType.lastUpdateUserId = request.user.sub;
|
||||
|
|
@ -98,6 +106,18 @@ export class EmployeePosTypeController extends Controller {
|
|||
if (chkEmpPosType) {
|
||||
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.lastUpdateFullName = request.user.name;
|
||||
this.employeePosTypeRepository.merge(EmpPosType, requestBody);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue