Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2024-12-03 13:54:33 +07:00
commit e1d7f6966e
5 changed files with 72 additions and 70 deletions

View file

@ -1615,10 +1615,10 @@ export class CommandController extends Controller {
persons: {
refId: string;
profileId?: string | null;
citizenId: string | null;
prefix: string | null;
firstName: string | null;
lastName: string | null;
citizenId?: string | null;
prefix?: string | null;
firstName?: string | null;
lastName?: string | null;
remarkVertical?: string | null;
remarkHorizontal?: string | null;
rootId?: string | null;
@ -2215,7 +2215,6 @@ export class CommandController extends Controller {
profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name;
profile.lastUpdatedAt = new Date();
// profile.dateStart = new Date();
if (item.isLeave == true) {
await removeProfileInOrganize(profile.id, "OFFICER");
}
@ -2236,21 +2235,25 @@ export class CommandController extends Controller {
const returnWork = await checkReturnCommandType(String(item.commandId));
//คำสั่งบรรจุกลับเข้ารับราชการ หรือ ผู้ออกไปรับราชการทหารกลับเข้ารับราชการ solutionเดิม ให้ enable user เปลี่ยนเป็นสร้าง user ใหม่เลยเพราะยังไงตอนถูกพักก็ถูกลบ user
if (returnWork && item.isGovernment) {
/*if (profile.keycloak != null) {
const enableActive = await enableStatus(profile.keycloak, true);
if (!enableActive) throw new Error("Failed. Cannot change enable status.");
} else {*/
const userKeycloakId = await createUser(profile.citizenId, profile.citizenId, {
firstName: profile.firstName,
lastName: profile.lastName,
});
// if (typeof userKeycloakId !== "string") {
// throw new Error(userKeycloakId.errorMessage);
// }
const list = await getRoles();
if (!Array.isArray(list))
throw new Error("Failed. Cannot get role(s) data from the server.");
const result = await addUserRoles(
let userKeycloakId;
userKeycloakId = await createUser(profile.citizenId, profile.citizenId, {
firstName: profile.firstName,
lastName: profile.lastName,
});
// กรณี Keycloak ไม่ถูกลบ ให้ลบซ้ำอีกรอบแล้วสร้างใหม่
if (profile.keycloak != null && userKeycloakId && userKeycloakId.error === "User exists with same username") {
const delUserKeycloak = await deleteUser(profile.keycloak);
if(delUserKeycloak) {
userKeycloakId = await createUser(profile.citizenId, profile.citizenId, {
firstName: profile.firstName,
lastName: profile.lastName,
});
}
}
const list = await getRoles();
let result = false;
if (Array.isArray(list) && userKeycloakId) {
result = await addUserRoles(
userKeycloakId,
list
.filter((v) => v.name === "USER")
@ -2259,10 +2262,9 @@ export class CommandController extends Controller {
name: x.name,
})),
);
// if (!result) throw new Error("Failed. Cannot set user's role.");
profile.keycloak = typeof userKeycloakId === "string" ? userKeycloakId : "";
/*}*/
}
profile.isActive = true;
profile.keycloak = typeof userKeycloakId === "string" ? userKeycloakId : "";
profile.roleKeycloaks = result && roleKeycloak ? [roleKeycloak] : [];
}
await this.profileRepository.save(profile);

View file

@ -199,7 +199,7 @@ export class OrganizationDotnetController extends Controller {
dateStart: item.dateStart,
govAgeAbsent: item.govAgeAbsent,
govAgePlus: item.govAgePlus,
birthDate: item.birthDate,
birthDate: item.birthDate ?? new Date(),
reasonSameDate: item.reasonSameDate,
ethnicity: item.ethnicity,
telephoneNumber: item.telephoneNumber,
@ -495,7 +495,7 @@ export class OrganizationDotnetController extends Controller {
dateStart: profile.dateStart,
govAgeAbsent: profile.govAgeAbsent,
govAgePlus: profile.govAgePlus,
birthDate: profile.birthDate,
birthDate: profile.birthDate ?? new Date(),
reasonSameDate: profile.reasonSameDate,
telephoneNumber: profile.telephoneNumber,
nationality: profile.nationality,
@ -732,7 +732,7 @@ export class OrganizationDotnetController extends Controller {
dateStart: profile.dateStart,
govAgeAbsent: profile.govAgeAbsent,
govAgePlus: profile.govAgePlus,
birthDate: profile.birthDate,
birthDate: profile.birthDate ?? new Date(),
reasonSameDate: profile.reasonSameDate,
telephoneNumber: profile.telephoneNumber,
nationality: profile.nationality,
@ -1028,7 +1028,7 @@ export class OrganizationDotnetController extends Controller {
dateStart: profile.dateStart,
govAgeAbsent: profile.govAgeAbsent,
govAgePlus: profile.govAgePlus,
birthDate: profile.birthDate,
birthDate: profile.birthDate ?? new Date(),
reasonSameDate: profile.reasonSameDate,
telephoneNumber: profile.telephoneNumber,
nationality: profile.nationality,
@ -1295,7 +1295,7 @@ export class OrganizationDotnetController extends Controller {
dateStart: profile.dateStart,
govAgeAbsent: profile.govAgeAbsent,
govAgePlus: profile.govAgePlus,
birthDate: profile.birthDate,
birthDate: profile.birthDate ?? new Date(),
reasonSameDate: profile.reasonSameDate,
telephoneNumber: profile.telephoneNumber,
nationality: profile.nationality,
@ -1621,7 +1621,7 @@ export class OrganizationDotnetController extends Controller {
dateStart: profile.dateStart,
govAgeAbsent: profile.govAgeAbsent,
govAgePlus: profile.govAgePlus,
birthDate: profile.birthDate,
birthDate: profile.birthDate ?? new Date(),
reasonSameDate: profile.reasonSameDate,
telephoneNumber: profile.telephoneNumber,
nationality: profile.nationality,
@ -1888,7 +1888,7 @@ export class OrganizationDotnetController extends Controller {
dateStart: profile.dateStart,
govAgeAbsent: profile.govAgeAbsent,
govAgePlus: profile.govAgePlus,
birthDate: profile.birthDate,
birthDate: profile.birthDate ?? new Date(),
reasonSameDate: profile.reasonSameDate,
telephoneNumber: profile.telephoneNumber,
nationality: profile.nationality,
@ -2072,7 +2072,7 @@ export class OrganizationDotnetController extends Controller {
dateStart: profile.dateStart,
govAgeAbsent: profile.govAgeAbsent,
govAgePlus: profile.govAgePlus,
birthDate: profile.birthDate,
birthDate: profile.birthDate ?? new Date(),
reasonSameDate: profile.reasonSameDate,
telephoneNumber: profile.telephoneNumber,
nationality: profile.nationality,
@ -2209,7 +2209,7 @@ export class OrganizationDotnetController extends Controller {
dateStart: profile.dateStart,
govAgeAbsent: profile.govAgeAbsent,
govAgePlus: profile.govAgePlus,
birthDate: profile.birthDate,
birthDate: profile.birthDate ?? new Date(),
reasonSameDate: profile.reasonSameDate,
telephoneNumber: profile.telephoneNumber,
nationality: profile.nationality,
@ -2316,7 +2316,7 @@ export class OrganizationDotnetController extends Controller {
firstName: profile.firstName,
lastName: profile.lastName,
citizenId: profile.citizenId,
birthDate: profile.birthDate,
birthDate: profile.birthDate ?? new Date(),
position: profile.position,
rootId: root == null ? null : root.id,
root: root == null ? null : root.orgRootName,
@ -2417,7 +2417,7 @@ export class OrganizationDotnetController extends Controller {
firstName: profile.firstName,
lastName: profile.lastName,
citizenId: profile.citizenId,
birthDate: profile.birthDate,
birthDate: profile.birthDate ?? new Date(),
position: profile.position,
posMaster: posMaster == null ? null : posMaster.posMasterNo,
posMasterNo: posMaster == null ? null : posMaster.posMasterNo,
@ -2589,7 +2589,7 @@ export class OrganizationDotnetController extends Controller {
dateStart: item.dateStart,
govAgeAbsent: item.govAgeAbsent,
govAgePlus: item.govAgePlus,
birthDate: item.birthDate,
birthDate: item.birthDate ?? new Date(),
reasonSameDate: item.reasonSameDate,
ethnicity: item.ethnicity,
telephoneNumber: item.telephoneNumber,