fix issue #1238 : กรณีถึงแก่กรรมปลดออกจากโครงสร้าง

This commit is contained in:
Bright 2025-03-13 14:15:28 +07:00
parent 7b955739ba
commit 8cd69646c1
3 changed files with 40 additions and 3 deletions

View file

@ -60,7 +60,7 @@ import { ProfileFamilyFather } from "../entities/ProfileFamilyFather";
import Extension from "../interfaces/extension";
import { ProfileInsignia } from "../entities/ProfileInsignia";
import { ProfileLeave } from "../entities/ProfileLeave";
import { updateName } from "../keycloak";
import { updateName, deleteUser } from "../keycloak";
import permission from "../interfaces/permission";
import { PosMasterAct } from "../entities/PosMasterAct";
import axios from "axios";
@ -9405,6 +9405,7 @@ export class ProfileController extends Controller {
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const before = structuredClone(profile);
let _null:any = null;
profile.isLeave = requestBody.isLeave;
profile.leaveReason = requestBody.leaveReason;
profile.dateLeave = requestBody.dateLeave;
@ -9412,6 +9413,17 @@ export class ProfileController extends Controller {
await removeProfileInOrganize(profile.id, "OFFICER");
}
profile.leaveType = "RETIRE_DECEASED";
profile.position = _null;
profile.posLevelId = _null;
profile.posTypeId = _null;
if (profile.keycloak != null) {
const delUserKeycloak = await deleteUser(profile.keycloak);
if (delUserKeycloak) {
profile.keycloak = _null;
profile.roleKeycloaks = [];
profile.isActive = false;
}
}
await this.profileRepo.save(profile, { data: request });
setLogDataDiff(request, { before, after: profile });