no message
This commit is contained in:
parent
102f1f6646
commit
44b8b516eb
6 changed files with 241 additions and 21 deletions
|
|
@ -127,8 +127,19 @@ export class ImportDataController extends Controller {
|
||||||
|
|
||||||
let dateRetire = new Date(item["BORN"]);
|
let dateRetire = new Date(item["BORN"]);
|
||||||
profile.citizenId = item["ID"] == "" ? "" : item["ID"];
|
profile.citizenId = item["ID"] == "" ? "" : item["ID"];
|
||||||
profile.rank = item["RANK_NAME"] == "" ? null : item["RANK_NAME"];
|
profile.rank =
|
||||||
|
item["RANK_NAME"] == "" ||
|
||||||
|
item["RANK_NAME"] == "นาย" ||
|
||||||
|
item["RANK_NAME"] == "นาง" ||
|
||||||
|
item["RANK_NAME"] == "นางสาว"
|
||||||
|
? null
|
||||||
|
: item["RANK_NAME"];
|
||||||
profile.prefix = item["RANK_NAME"] == "" ? null : item["RANK_NAME"];
|
profile.prefix = item["RANK_NAME"] == "" ? null : item["RANK_NAME"];
|
||||||
|
profile.prefixMain =
|
||||||
|
item["RANK_NAME"] == "" ||
|
||||||
|
(item["RANK_NAME"] != "นาย" && item["RANK_NAME"] != "นาง" && item["RANK_NAME"] != "นางสาว")
|
||||||
|
? null
|
||||||
|
: item["RANK_NAME"];
|
||||||
profile.firstName = item["FNAME"] == "" ? null : item["FNAME"];
|
profile.firstName = item["FNAME"] == "" ? null : item["FNAME"];
|
||||||
profile.lastName = item["LNAME"] == "" ? null : item["LNAME"];
|
profile.lastName = item["LNAME"] == "" ? null : item["LNAME"];
|
||||||
profile.gender = item["SEX"] == "1" ? "ชาย" : item["SEX"] == "2" ? "หญิง" : null_;
|
profile.gender = item["SEX"] == "1" ? "ชาย" : item["SEX"] == "2" ? "หญิง" : null_;
|
||||||
|
|
@ -209,8 +220,19 @@ export class ImportDataController extends Controller {
|
||||||
profileEmp.citizenId = item["ID"] == "" ? "" : item["ID"];
|
profileEmp.citizenId = item["ID"] == "" ? "" : item["ID"];
|
||||||
profileEmp.employeeClass =
|
profileEmp.employeeClass =
|
||||||
item["FLAG_PERSON_TYPE"] == "6" ? "PERM" : item["FLAG_PERSON_TYPE"] == "7" ? "TEMP" : "";
|
item["FLAG_PERSON_TYPE"] == "6" ? "PERM" : item["FLAG_PERSON_TYPE"] == "7" ? "TEMP" : "";
|
||||||
profileEmp.rank = item["RANK_NAME"] == "" ? null : item["RANK_NAME"];
|
profileEmp.rank =
|
||||||
|
item["RANK_NAME"] == "" ||
|
||||||
|
item["RANK_NAME"] == "นาย" ||
|
||||||
|
item["RANK_NAME"] == "นาง" ||
|
||||||
|
item["RANK_NAME"] == "นางสาว"
|
||||||
|
? null
|
||||||
|
: item["RANK_NAME"];
|
||||||
profileEmp.prefix = item["RANK_NAME"] == "" ? null : item["RANK_NAME"];
|
profileEmp.prefix = item["RANK_NAME"] == "" ? null : item["RANK_NAME"];
|
||||||
|
profileEmp.prefixMain =
|
||||||
|
item["RANK_NAME"] == "" ||
|
||||||
|
(item["RANK_NAME"] != "นาย" && item["RANK_NAME"] != "นาง" && item["RANK_NAME"] != "นางสาว")
|
||||||
|
? null
|
||||||
|
: item["RANK_NAME"];
|
||||||
profileEmp.firstName = item["FNAME"] == "" ? null : item["FNAME"];
|
profileEmp.firstName = item["FNAME"] == "" ? null : item["FNAME"];
|
||||||
profileEmp.lastName = item["LNAME"] == "" ? null : item["LNAME"];
|
profileEmp.lastName = item["LNAME"] == "" ? null : item["LNAME"];
|
||||||
profileEmp.gender = item["SEX"] == "1" ? "ชาย" : item["SEX"] == "2" ? "หญิง" : null_;
|
profileEmp.gender = item["SEX"] == "1" ? "ชาย" : item["SEX"] == "2" ? "หญิง" : null_;
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,6 @@ import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHisto
|
||||||
import { viewDirector } from "../entities/view/viewDirector";
|
import { viewDirector } from "../entities/view/viewDirector";
|
||||||
import { viewDirectorActing } from "../entities/view/viewDirectorActing";
|
import { viewDirectorActing } from "../entities/view/viewDirectorActing";
|
||||||
import CallAPI from "../interfaces/call-api";
|
import CallAPI from "../interfaces/call-api";
|
||||||
import { log } from "console";
|
|
||||||
import { Subject } from "typeorm/persistence/Subject.js";
|
|
||||||
@Route("api/v1/org/profile")
|
@Route("api/v1/org/profile")
|
||||||
@Tags("Profile")
|
@Tags("Profile")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -1734,6 +1732,33 @@ export class ProfileController extends Controller {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่งนี้");
|
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.posTypeId && !(await this.posTypeRepo.findOneBy({ id: body.posTypeId }))) {
|
if (body.posTypeId && !(await this.posTypeRepo.findOneBy({ id: body.posTypeId }))) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
|
||||||
}
|
}
|
||||||
|
|
@ -1781,6 +1806,8 @@ export class ProfileController extends Controller {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
const profile = Object.assign(new Profile(), body);
|
const profile = Object.assign(new Profile(), body);
|
||||||
|
profile.prefixMain = profile.prefix;
|
||||||
|
profile.prefix = profile.rank ?? profile.prefixMain;
|
||||||
profile.isProbation = false;
|
profile.isProbation = false;
|
||||||
profile.isLeave = false;
|
profile.isLeave = false;
|
||||||
profile.createdUserId = request.user.sub;
|
profile.createdUserId = request.user.sub;
|
||||||
|
|
@ -1823,8 +1850,37 @@ export class ProfileController extends Controller {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
|
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 profile: Profile = Object.assign(new Profile(), body);
|
const profile: Profile = Object.assign(new Profile(), body);
|
||||||
const _null: any = null;
|
const _null: any = null;
|
||||||
|
profile.prefixMain = profile.prefix;
|
||||||
|
profile.prefix = profile.rank ?? profile.prefixMain;
|
||||||
profile.dateRetire = body.birthDate == null ? _null : calculateRetireDate(body.birthDate);
|
profile.dateRetire = body.birthDate == null ? _null : calculateRetireDate(body.birthDate);
|
||||||
profile.dateRetireLaw = body.birthDate == null ? _null : calculateRetireLaw(body.birthDate);
|
profile.dateRetireLaw = body.birthDate == null ? _null : calculateRetireLaw(body.birthDate);
|
||||||
profile.createdUserId = request.user.sub;
|
profile.createdUserId = request.user.sub;
|
||||||
|
|
@ -1864,7 +1920,36 @@ export class ProfileController extends Controller {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
|
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 profile: Profile = Object.assign(new Profile(), body);
|
const profile: Profile = Object.assign(new Profile(), body);
|
||||||
|
profile.prefixMain = profile.prefix;
|
||||||
|
profile.prefix = profile.rank ?? profile.prefixMain;
|
||||||
profile.createdUserId = request.user.sub;
|
profile.createdUserId = request.user.sub;
|
||||||
profile.createdFullName = request.user.name;
|
profile.createdFullName = request.user.name;
|
||||||
profile.lastUpdateUserId = request.user.sub;
|
profile.lastUpdateUserId = request.user.sub;
|
||||||
|
|
@ -1880,15 +1965,19 @@ export class ProfileController extends Controller {
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
profileId: string;
|
profileId: string;
|
||||||
email: string;
|
email: string;
|
||||||
subject: string;
|
subject: string;
|
||||||
}
|
},
|
||||||
) {
|
) {
|
||||||
const jwt = require('jsonwebtoken');
|
const jwt = require("jsonwebtoken");
|
||||||
const token = jwt.sign({email_id: body.email, profileId: body.profileId}, process.env.AUTH_ACCOUNT_SECRET, {expiresIn: '15m'});
|
const token = jwt.sign(
|
||||||
// console.log("[token]",token);
|
{ email_id: body.email, profileId: body.profileId },
|
||||||
const link = process.env.URL + "/verifyemail?upn=" + token;
|
process.env.AUTH_ACCOUNT_SECRET,
|
||||||
// console.log("[link]",link);
|
{ expiresIn: "15m" },
|
||||||
|
);
|
||||||
|
// console.log("[token]",token);
|
||||||
|
const link = process.env.URL + "/verifyemail?upn=" + token;
|
||||||
|
// console.log("[link]",link);
|
||||||
|
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(req, "/placement/noti/send-mail", {
|
.PostData(req, "/placement/noti/send-mail", {
|
||||||
|
|
@ -3172,6 +3261,8 @@ export class ProfileController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
|
record.prefixMain = record.prefix;
|
||||||
|
record.prefix = record.rank ?? record.prefixMain;
|
||||||
record.createdUserId = request.user.sub;
|
record.createdUserId = request.user.sub;
|
||||||
record.createdFullName = request.user.name;
|
record.createdFullName = request.user.name;
|
||||||
record.createdAt = new Date();
|
record.createdAt = new Date();
|
||||||
|
|
@ -3418,13 +3509,10 @@ export class ProfileController extends Controller {
|
||||||
} else if (chkDigit === 11) {
|
} else if (chkDigit === 11) {
|
||||||
chkDigit = chkDigit % 10;
|
chkDigit = chkDigit % 10;
|
||||||
}
|
}
|
||||||
// else if(chkDigit === 11){
|
|
||||||
// chkDigit = cal % 10;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (citizenIdDigits[12] !== chkDigit) {
|
if (citizenIdDigits[12] !== chkDigit) {
|
||||||
// throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
const record = await this.profileRepo.findOneBy({ id });
|
const record = await this.profileRepo.findOneBy({ id });
|
||||||
const before = structuredClone(record);
|
const before = structuredClone(record);
|
||||||
|
|
@ -3432,6 +3520,8 @@ export class ProfileController extends Controller {
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
|
record.prefixMain = record.prefix;
|
||||||
|
record.prefix = record.rank ?? record.prefixMain;
|
||||||
record.createdUserId = request.user.sub;
|
record.createdUserId = request.user.sub;
|
||||||
record.createdFullName = request.user.name;
|
record.createdFullName = request.user.name;
|
||||||
record.createdAt = new Date();
|
record.createdAt = new Date();
|
||||||
|
|
@ -7779,6 +7869,8 @@ export class ProfileController extends Controller {
|
||||||
profile.registrationSubDistrictId = _null;
|
profile.registrationSubDistrictId = _null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
profile.prefixMain = profile.prefix;
|
||||||
|
profile.prefix = profile.rank ?? profile.prefixMain;
|
||||||
profile.createdUserId = request.user.sub;
|
profile.createdUserId = request.user.sub;
|
||||||
profile.createdFullName = request.user.name;
|
profile.createdFullName = request.user.name;
|
||||||
profile.lastUpdateUserId = request.user.sub;
|
profile.lastUpdateUserId = request.user.sub;
|
||||||
|
|
|
||||||
|
|
@ -794,6 +794,33 @@ export class ProfileEmployeeController extends Controller {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
|
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 == "") {
|
if (body.employeeClass == null || body.employeeClass == undefined || body.employeeClass == "") {
|
||||||
body.employeeClass = "PERM";
|
body.employeeClass = "PERM";
|
||||||
}
|
}
|
||||||
|
|
@ -802,6 +829,8 @@ export class ProfileEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = Object.assign(new ProfileEmployee(), body);
|
const profile = Object.assign(new ProfileEmployee(), body);
|
||||||
|
profile.prefixMain = profile.prefix;
|
||||||
|
profile.prefix = profile.rank ?? profile.prefixMain;
|
||||||
profile.createdUserId = request.user.sub;
|
profile.createdUserId = request.user.sub;
|
||||||
profile.createdFullName = request.user.name;
|
profile.createdFullName = request.user.name;
|
||||||
profile.lastUpdateUserId = request.user.sub;
|
profile.lastUpdateUserId = request.user.sub;
|
||||||
|
|
@ -830,7 +859,10 @@ export class ProfileEmployeeController extends Controller {
|
||||||
@Path() id: string,
|
@Path() id: string,
|
||||||
@Body() body: UpdateProfileEmployee,
|
@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 =
|
const exists =
|
||||||
!!body.citizenId &&
|
!!body.citizenId &&
|
||||||
(await this.profileRepo.findOne({
|
(await this.profileRepo.findOne({
|
||||||
|
|
@ -856,6 +888,33 @@ export class ProfileEmployeeController extends Controller {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
|
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 });
|
const record = await this.profileRepo.findOneBy({ id });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||||
|
|
||||||
|
|
@ -867,6 +926,8 @@ export class ProfileEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
|
record.prefixMain = record.prefix;
|
||||||
|
record.prefix = record.rank ?? record.prefixMain;
|
||||||
record.createdUserId = request.user.sub;
|
record.createdUserId = request.user.sub;
|
||||||
record.createdFullName = request.user.name;
|
record.createdFullName = request.user.name;
|
||||||
record.createdAt = new Date();
|
record.createdAt = new Date();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,13 @@
|
||||||
import { Entity, Column, OneToMany, JoinColumn, ManyToOne, Double, ManyToMany, JoinTable } from "typeorm";
|
import {
|
||||||
|
Entity,
|
||||||
|
Column,
|
||||||
|
OneToMany,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
Double,
|
||||||
|
ManyToMany,
|
||||||
|
JoinTable,
|
||||||
|
} from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { PosMaster } from "./PosMaster";
|
import { PosMaster } from "./PosMaster";
|
||||||
import { PosLevel } from "./PosLevel";
|
import { PosLevel } from "./PosLevel";
|
||||||
|
|
@ -69,6 +78,14 @@ export class Profile extends EntityBase {
|
||||||
})
|
})
|
||||||
prefix: string;
|
prefix: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "คำนำหน้าชื่อตัวหลัก",
|
||||||
|
length: 40,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
prefixMain: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ชื่อ",
|
comment: "ชื่อ",
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,14 @@ export class ProfileEmployee extends EntityBase {
|
||||||
})
|
})
|
||||||
prefix: string;
|
prefix: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "คำนำหน้าชื่อตัวหลัก",
|
||||||
|
length: 40,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
prefixMain: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ชื่อ",
|
comment: "ชื่อ",
|
||||||
|
|
|
||||||
20
src/migration/1732252198299-updata_profile_add_prefixmain.ts
Normal file
20
src/migration/1732252198299-updata_profile_add_prefixmain.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdataProfileAddPrefixmain1732252198299 implements MigrationInterface {
|
||||||
|
name = 'UpdataProfileAddPrefixmain1732252198299'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`prefixMain\` varchar(40) NULL COMMENT 'คำนำหน้าชื่อตัวหลัก'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`prefixMain\` varchar(40) NULL COMMENT 'คำนำหน้าชื่อตัวหลัก'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` ADD \`prefixMain\` varchar(40) NULL COMMENT 'คำนำหน้าชื่อตัวหลัก'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`prefixMain\` varchar(40) NULL COMMENT 'คำนำหน้าชื่อตัวหลัก'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`prefixMain\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`prefixMain\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`prefixMain\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`prefixMain\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue