fix issue #1238 : กรณีถึงแก่กรรมปลดออกจากโครงสร้าง
This commit is contained in:
parent
7b955739ba
commit
8cd69646c1
3 changed files with 40 additions and 3 deletions
|
|
@ -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 });
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ import permission from "../interfaces/permission";
|
|||
import axios from "axios";
|
||||
import { Position } from "../entities/Position";
|
||||
import { EmployeePosition } from "../entities/EmployeePosition";
|
||||
import { deleteUser } from "../keycloak";
|
||||
@Route("api/v1/org/profile-employee")
|
||||
@Tags("ProfileEmployee")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -4113,13 +4114,24 @@ export class ProfileEmployeeController extends Controller {
|
|||
where: { id: id },
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
let _null:any = null;
|
||||
profile.isLeave = requestBody.isLeave;
|
||||
profile.leaveReason = requestBody.leaveReason;
|
||||
profile.dateLeave = requestBody.dateLeave;
|
||||
if (requestBody.isLeave == true) {
|
||||
await removeProfileInOrganize(profile.id, "EMPLOYEE");
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
profile.leaveType = "RETIRE_DECEASED";
|
||||
await this.profileRepo.save(profile);
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ import { ProfileInsignia } from "../entities/ProfileInsignia";
|
|||
import { ProfileLeave } from "../entities/ProfileLeave";
|
||||
import permission from "../interfaces/permission";
|
||||
import axios from "axios";
|
||||
import { deleteUser } from "../keycloak";
|
||||
@Route("api/v1/org/profile-temp")
|
||||
@Tags("ProfileEmployee")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -3201,13 +3202,25 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
where: { id: id },
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
let _null:any = null;
|
||||
profile.isLeave = requestBody.isLeave;
|
||||
profile.leaveReason = requestBody.leaveReason;
|
||||
profile.dateLeave = requestBody.dateLeave;
|
||||
if (requestBody.isLeave == true) {
|
||||
await removeProfileInOrganize(profile.id, "EMPLOYEE");
|
||||
}
|
||||
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);
|
||||
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue