diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index d9428e27..aa2ab3d1 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -6245,17 +6245,17 @@ export class CommandController extends Controller { .orgRootShortName ?? ""; } } + const before = null; + const meta = { + createdUserId: req.user.sub, + createdFullName: req.user.name, + lastUpdateUserId: req.user.sub, + lastUpdateFullName: req.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), + }; await Promise.all( body.data.map(async (item) => { - const before = null; - const meta = { - createdUserId: req.user.sub, - createdFullName: req.user.name, - lastUpdateUserId: req.user.sub, - lastUpdateFullName: req.user.name, - createdAt: new Date(), - lastUpdatedAt: new Date(), - }; const _null: any = null; if (item.bodyProfile.posLevelId === "") item.bodyProfile.posLevelId = null; if (item.bodyProfile.posTypeId === "") item.bodyProfile.posTypeId = null; @@ -6306,13 +6306,6 @@ export class CommandController extends Controller { if (checkUser.length == 0) { let password = item.bodyProfile.citizenId; if (item.bodyProfile.birthDate != null) { - // const gregorianYear = item.bodyProfile.birthDate.getFullYear() + 543; - - // const formattedDate = - // item.bodyProfile.birthDate.toISOString().slice(8, 10) + - // item.bodyProfile.birthDate.toISOString().slice(5, 7) + - // gregorianYear; - // password = formattedDate; const _date = new Date(item.bodyProfile.birthDate.toDateString()) .getDate() .toString() @@ -6336,7 +6329,8 @@ export class CommandController extends Controller { name: x.name, })), ); - } else { + } + else { userKeycloakId = checkUser[0].id; const rolesData = await getRoleMappings(userKeycloakId); if (rolesData) { @@ -6397,12 +6391,12 @@ export class CommandController extends Controller { } await removeProfileInOrganize(profileEmployee.id, "EMPLOYEE"); if (profileEmployee.keycloak != null) { - const delUserKeycloak = await deleteUser(profileEmployee.keycloak); - if (delUserKeycloak) { + // const delUserKeycloak = await deleteUser(profileEmployee.keycloak); + // if (delUserKeycloak) { profileEmployee.keycloak = _null; profileEmployee.roleKeycloaks = []; profileEmployee.isActive = false; - } + // } } profileEmployee.isLeave = true; profileEmployee.leaveReason = "บรรจุข้าราชการ";