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

@ -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();