Merge branch 'develop' of github.com:Frappet/hrms-api-org into develop

This commit is contained in:
kittapath 2025-03-13 15:00:33 +07:00
commit 177577acf0
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 Extension from "../interfaces/extension";
import { ProfileInsignia } from "../entities/ProfileInsignia"; import { ProfileInsignia } from "../entities/ProfileInsignia";
import { ProfileLeave } from "../entities/ProfileLeave"; import { ProfileLeave } from "../entities/ProfileLeave";
import { updateName } from "../keycloak"; import { updateName, deleteUser } from "../keycloak";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
import { PosMasterAct } from "../entities/PosMasterAct"; import { PosMasterAct } from "../entities/PosMasterAct";
import axios from "axios"; import axios from "axios";
@ -9405,6 +9405,7 @@ export class ProfileController extends Controller {
}); });
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const before = structuredClone(profile); const before = structuredClone(profile);
let _null:any = null;
profile.isLeave = requestBody.isLeave; profile.isLeave = requestBody.isLeave;
profile.leaveReason = requestBody.leaveReason; profile.leaveReason = requestBody.leaveReason;
profile.dateLeave = requestBody.dateLeave; profile.dateLeave = requestBody.dateLeave;
@ -9412,6 +9413,17 @@ export class ProfileController extends Controller {
await removeProfileInOrganize(profile.id, "OFFICER"); await removeProfileInOrganize(profile.id, "OFFICER");
} }
profile.leaveType = "RETIRE_DECEASED"; 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 }); await this.profileRepo.save(profile, { data: request });
setLogDataDiff(request, { before, after: profile }); setLogDataDiff(request, { before, after: profile });

View file

@ -68,6 +68,7 @@ import permission from "../interfaces/permission";
import axios from "axios"; import axios from "axios";
import { Position } from "../entities/Position"; import { Position } from "../entities/Position";
import { EmployeePosition } from "../entities/EmployeePosition"; import { EmployeePosition } from "../entities/EmployeePosition";
import { deleteUser } from "../keycloak";
@Route("api/v1/org/profile-employee") @Route("api/v1/org/profile-employee")
@Tags("ProfileEmployee") @Tags("ProfileEmployee")
@Security("bearerAuth") @Security("bearerAuth")
@ -4113,13 +4114,24 @@ export class ProfileEmployeeController extends Controller {
where: { id: id }, where: { id: id },
}); });
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
let _null:any = null;
profile.isLeave = requestBody.isLeave; profile.isLeave = requestBody.isLeave;
profile.leaveReason = requestBody.leaveReason; profile.leaveReason = requestBody.leaveReason;
profile.dateLeave = requestBody.dateLeave; profile.dateLeave = requestBody.dateLeave;
if (requestBody.isLeave == true) { if (requestBody.isLeave == true) {
await removeProfileInOrganize(profile.id, "EMPLOYEE"); 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"; profile.leaveType = "RETIRE_DECEASED";
await this.profileRepo.save(profile); await this.profileRepo.save(profile);

View file

@ -66,6 +66,7 @@ import { ProfileInsignia } from "../entities/ProfileInsignia";
import { ProfileLeave } from "../entities/ProfileLeave"; import { ProfileLeave } from "../entities/ProfileLeave";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
import axios from "axios"; import axios from "axios";
import { deleteUser } from "../keycloak";
@Route("api/v1/org/profile-temp") @Route("api/v1/org/profile-temp")
@Tags("ProfileEmployee") @Tags("ProfileEmployee")
@Security("bearerAuth") @Security("bearerAuth")
@ -3201,13 +3202,25 @@ export class ProfileEmployeeTempController extends Controller {
where: { id: id }, where: { id: id },
}); });
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
let _null:any = null;
profile.isLeave = requestBody.isLeave; profile.isLeave = requestBody.isLeave;
profile.leaveReason = requestBody.leaveReason; profile.leaveReason = requestBody.leaveReason;
profile.dateLeave = requestBody.dateLeave; profile.dateLeave = requestBody.dateLeave;
if (requestBody.isLeave == true) { if (requestBody.isLeave == true) {
await removeProfileInOrganize(profile.id, "EMPLOYEE"); 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); await this.profileRepo.save(profile);
return new HttpSuccess(); return new HttpSuccess();