no message
This commit is contained in:
parent
102f1f6646
commit
44b8b516eb
6 changed files with 241 additions and 21 deletions
|
|
@ -794,6 +794,33 @@ export class ProfileEmployeeController extends Controller {
|
|||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
|
||||
}
|
||||
|
||||
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;
|
||||
let chkDigit = 11 - calStp2;
|
||||
if (chkDigit === 10) {
|
||||
chkDigit = 1;
|
||||
} else if (chkDigit === 11) {
|
||||
chkDigit = chkDigit % 10;
|
||||
}
|
||||
|
||||
if (citizenIdDigits[12] !== chkDigit) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
|
||||
}
|
||||
}
|
||||
if (body.employeeClass == null || body.employeeClass == undefined || body.employeeClass == "") {
|
||||
body.employeeClass = "PERM";
|
||||
}
|
||||
|
|
@ -802,6 +829,8 @@ export class ProfileEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
const profile = Object.assign(new ProfileEmployee(), body);
|
||||
profile.prefixMain = profile.prefix;
|
||||
profile.prefix = profile.rank ?? profile.prefixMain;
|
||||
profile.createdUserId = request.user.sub;
|
||||
profile.createdFullName = request.user.name;
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
|
|
@ -830,7 +859,10 @@ export class ProfileEmployeeController extends Controller {
|
|||
@Path() id: string,
|
||||
@Body() body: UpdateProfileEmployee,
|
||||
) {
|
||||
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", id);
|
||||
const _record = await this.profileRepo.findOneBy({ id: id });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", _record.id);
|
||||
}
|
||||
const exists =
|
||||
!!body.citizenId &&
|
||||
(await this.profileRepo.findOne({
|
||||
|
|
@ -856,6 +888,33 @@ export class ProfileEmployeeController extends Controller {
|
|||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
|
||||
}
|
||||
|
||||
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;
|
||||
let chkDigit = 11 - calStp2;
|
||||
if (chkDigit === 10) {
|
||||
chkDigit = 1;
|
||||
} else if (chkDigit === 11) {
|
||||
chkDigit = chkDigit % 10;
|
||||
}
|
||||
|
||||
if (citizenIdDigits[12] !== chkDigit) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
|
||||
}
|
||||
}
|
||||
const record = await this.profileRepo.findOneBy({ id });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||
|
||||
|
|
@ -867,6 +926,8 @@ export class ProfileEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
Object.assign(record, body);
|
||||
record.prefixMain = record.prefix;
|
||||
record.prefix = record.rank ?? record.prefixMain;
|
||||
record.createdUserId = request.user.sub;
|
||||
record.createdFullName = request.user.name;
|
||||
record.createdAt = new Date();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue