fix แก้ไขประวัติส่วนตัว ไม่ปั๊มประวัติรายการคนครอง #244
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m9s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m9s
This commit is contained in:
parent
ccfb2754fd
commit
521a748de1
2 changed files with 9 additions and 40 deletions
|
|
@ -93,6 +93,7 @@ import { CreatePosMasterHistoryOfficer, getTopDegrees, getPosMasterPositions } f
|
|||
import { ProfileLeaveService } from "../services/ProfileLeaveService";
|
||||
// import { PostRetireToExprofile } from "./ExRetirementController";
|
||||
import { getPosNumCodeSit } from "../services/CommandService";
|
||||
import { updateHolderProfileHistory } from "../services/PositionService";
|
||||
@Route("api/v1/org/profile")
|
||||
@Tags("Profile")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -5774,26 +5775,7 @@ export class ProfileController extends Controller {
|
|||
}
|
||||
|
||||
if (body.citizenId) {
|
||||
const citizenIdDigits = body.citizenId.toString().split("").map(Number);
|
||||
const cal =
|
||||
citizenIdDigits[0] * 13 +
|
||||
citizenIdDigits[1] * 12 +
|
||||
citizenIdDigits[2] * 11 +
|
||||
citizenIdDigits[3] * 10 +
|
||||
citizenIdDigits[4] * 9 +
|
||||
citizenIdDigits[5] * 8 +
|
||||
citizenIdDigits[6] * 7 +
|
||||
citizenIdDigits[7] * 6 +
|
||||
citizenIdDigits[8] * 5 +
|
||||
citizenIdDigits[9] * 4 +
|
||||
citizenIdDigits[10] * 3 +
|
||||
citizenIdDigits[11] * 2;
|
||||
const calStp2 = cal % 11;
|
||||
const chkDigit = (11 - calStp2) % 10;
|
||||
|
||||
if (citizenIdDigits[12] !== chkDigit) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
|
||||
}
|
||||
Extension.CheckCitizen(body.citizenId);
|
||||
}
|
||||
const record = await this.profileRepo.findOneBy({ id });
|
||||
const before = structuredClone(record);
|
||||
|
|
@ -5833,6 +5815,9 @@ export class ProfileController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
// บันทึกประวัติคนครองตำแหน่ง (ถ้า profile นี้ครองตำแหน่งอยู่)
|
||||
await updateHolderProfileHistory(record.id, request);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ import { ProfileDuty } from "../entities/ProfileDuty";
|
|||
import { CreatePosMasterHistoryEmployee, getTopDegrees } from "../services/PositionService";
|
||||
import { ProfileLeaveService } from "../services/ProfileLeaveService";
|
||||
import { CommandCode } from "../entities/CommandCode";
|
||||
import { updateHolderProfileHistory } from "../services/PositionService";
|
||||
@Route("api/v1/org/profile-employee")
|
||||
@Tags("ProfileEmployee")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -2381,26 +2382,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
if (body.citizenId) {
|
||||
const citizenIdDigits = body.citizenId.toString().split("").map(Number);
|
||||
const cal =
|
||||
citizenIdDigits[0] * 13 +
|
||||
citizenIdDigits[1] * 12 +
|
||||
citizenIdDigits[2] * 11 +
|
||||
citizenIdDigits[3] * 10 +
|
||||
citizenIdDigits[4] * 9 +
|
||||
citizenIdDigits[5] * 8 +
|
||||
citizenIdDigits[6] * 7 +
|
||||
citizenIdDigits[7] * 6 +
|
||||
citizenIdDigits[8] * 5 +
|
||||
citizenIdDigits[9] * 4 +
|
||||
citizenIdDigits[10] * 3 +
|
||||
citizenIdDigits[11] * 2;
|
||||
const calStp2 = cal % 11;
|
||||
const chkDigit = (11 - calStp2) % 10;
|
||||
|
||||
if (citizenIdDigits[12] !== chkDigit) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
|
||||
}
|
||||
Extension.CheckCitizen(body.citizenId);
|
||||
}
|
||||
const record = await this.profileRepo.findOneBy({ id });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||
|
|
@ -2434,6 +2416,8 @@ export class ProfileEmployeeController extends Controller {
|
|||
}),
|
||||
);
|
||||
await this.profileRepo.save(record);
|
||||
// บันทึกประวัติคนครองตำแหน่ง (ถ้า profile นี้ครองตำแหน่งอยู่)
|
||||
await updateHolderProfileHistory(record.id, request, "EMPLOYEE");
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue