[Fix] กรณีพ้นราชการแก้ไขเป็นไม่ต้อง clear ฟิลด์ keycloak #228
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m7s

This commit is contained in:
harid 2026-04-01 17:50:38 +07:00
parent dc31ec0d7d
commit d553c1406c
5 changed files with 48 additions and 31 deletions

View file

@ -1657,7 +1657,8 @@ export class CommandController extends Controller {
// console.log("4. disable keycloak/authen") // console.log("4. disable keycloak/authen")
const delUserKeycloak = await deleteUser(_profile.keycloak, adminToken); const delUserKeycloak = await deleteUser(_profile.keycloak, adminToken);
if (delUserKeycloak) { if (delUserKeycloak) {
_profile.keycloak = ""; // Task #228
// _profile.keycloak = "";
_profile.roleKeycloaks = []; _profile.roleKeycloaks = [];
} }
} }
@ -1713,7 +1714,8 @@ export class CommandController extends Controller {
// disable keycloak/authen // disable keycloak/authen
const delUserKeycloak = await deleteUser(_profileEmp.keycloak, adminToken); const delUserKeycloak = await deleteUser(_profileEmp.keycloak, adminToken);
if (delUserKeycloak) { if (delUserKeycloak) {
_profileEmp.keycloak = ""; // Task #228
// _profileEmp.keycloak = "";
_profileEmp.roleKeycloaks = []; _profileEmp.roleKeycloaks = [];
} }
} }
@ -4128,7 +4130,8 @@ export class CommandController extends Controller {
if (profile.keycloak != null) { if (profile.keycloak != null) {
const delUserKeycloak = await deleteUser(profile.keycloak); const delUserKeycloak = await deleteUser(profile.keycloak);
if (delUserKeycloak) { if (delUserKeycloak) {
profile.keycloak = _null; // Task #228
// profile.keycloak = _null;
profile.roleKeycloaks = []; profile.roleKeycloaks = [];
profile.isActive = false; profile.isActive = false;
} }
@ -4532,7 +4535,8 @@ export class CommandController extends Controller {
if (profile.keycloak != null) { if (profile.keycloak != null) {
const delUserKeycloak = await deleteUser(profile.keycloak); const delUserKeycloak = await deleteUser(profile.keycloak);
if (delUserKeycloak) { if (delUserKeycloak) {
profile.keycloak = _null; // Task #228
// profile.keycloak = _null;
profile.roleKeycloaks = []; profile.roleKeycloaks = [];
profile.isActive = false; profile.isActive = false;
} }
@ -4752,7 +4756,8 @@ export class CommandController extends Controller {
if (profile.keycloak != null) { if (profile.keycloak != null) {
const delUserKeycloak = await deleteUser(profile.keycloak); const delUserKeycloak = await deleteUser(profile.keycloak);
if (delUserKeycloak) { if (delUserKeycloak) {
profile.keycloak = _null; // Task #228
// profile.keycloak = _null;
profile.roleKeycloaks = []; profile.roleKeycloaks = [];
profile.isActive = false; profile.isActive = false;
} }
@ -5248,7 +5253,8 @@ export class CommandController extends Controller {
if (_profile.keycloak != null) { if (_profile.keycloak != null) {
const delUserKeycloak = await deleteUser(_profile.keycloak); const delUserKeycloak = await deleteUser(_profile.keycloak);
if (delUserKeycloak) { if (delUserKeycloak) {
_profile.keycloak = _null; // Task #228
// _profile.keycloak = _null;
_profile.roleKeycloaks = []; _profile.roleKeycloaks = [];
_profile.isActive = false; _profile.isActive = false;
} }
@ -5431,7 +5437,8 @@ export class CommandController extends Controller {
if (_profile.keycloak != null) { if (_profile.keycloak != null) {
const delUserKeycloak = await deleteUser(_profile.keycloak); const delUserKeycloak = await deleteUser(_profile.keycloak);
if (delUserKeycloak) { if (delUserKeycloak) {
_profile.keycloak = _null; // Task #228
// _profile.keycloak = _null;
_profile.roleKeycloaks = []; _profile.roleKeycloaks = [];
_profile.isActive = false; _profile.isActive = false;
} }
@ -5769,7 +5776,8 @@ export class CommandController extends Controller {
if (_profile.keycloak != null) { if (_profile.keycloak != null) {
const delUserKeycloak = await deleteUser(_profile.keycloak); const delUserKeycloak = await deleteUser(_profile.keycloak);
if (delUserKeycloak) { if (delUserKeycloak) {
_profile.keycloak = _null; // Task #228
// _profile.keycloak = _null;
_profile.roleKeycloaks = []; _profile.roleKeycloaks = [];
_profile.isActive = false; _profile.isActive = false;
} }
@ -6206,7 +6214,8 @@ export class CommandController extends Controller {
if (_profile.keycloak != null) { if (_profile.keycloak != null) {
const delUserKeycloak = await deleteUser(_profile.keycloak); const delUserKeycloak = await deleteUser(_profile.keycloak);
if (delUserKeycloak) { if (delUserKeycloak) {
_profile.keycloak = _null; // Task #228
// _profile.keycloak = _null;
_profile.roleKeycloaks = []; _profile.roleKeycloaks = [];
_profile.isActive = false; _profile.isActive = false;
} }
@ -6503,7 +6512,8 @@ export class CommandController extends Controller {
if (profileEmployee.keycloak != null) { if (profileEmployee.keycloak != null) {
// const delUserKeycloak = await deleteUser(profileEmployee.keycloak); // const delUserKeycloak = await deleteUser(profileEmployee.keycloak);
// if (delUserKeycloak) { // if (delUserKeycloak) {
profileEmployee.keycloak = _null; // Task #228
// profileEmployee.keycloak = _null;
profileEmployee.roleKeycloaks = []; profileEmployee.roleKeycloaks = [];
profileEmployee.isActive = false; profileEmployee.isActive = false;
// } // }

View file

@ -11133,9 +11133,9 @@ export class ProfileController extends Controller {
} }
/** /**
* API * API
* *
* @summary (ADMIN) * @summary (ADMIN)
* *
* @param {string} id Id * @param {string} id Id
*/ */
@ -11263,7 +11263,8 @@ export class ProfileController extends Controller {
if (profile.keycloak != null) { if (profile.keycloak != null) {
const delUserKeycloak = await deleteUser(profile.keycloak); const delUserKeycloak = await deleteUser(profile.keycloak);
if (delUserKeycloak) { if (delUserKeycloak) {
profile.keycloak = _null; // Task #228
// profile.keycloak = _null;
profile.roleKeycloaks = []; profile.roleKeycloaks = [];
profile.isActive = false; profile.isActive = false;
} }
@ -11371,7 +11372,7 @@ export class ProfileController extends Controller {
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
.where("profile.keycloak IS NULL") .where("profile.isActive = :isActive", { isActive: false })
.andWhere( .andWhere(
new Brackets((qb) => { new Brackets((qb) => {
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` }); qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });

View file

@ -5560,9 +5560,9 @@ export class ProfileEmployeeController extends Controller {
} }
/** /**
* API * API
* *
* @summary (ADMIN) * @summary (ADMIN)
* *
* @param {string} id Id * @param {string} id Id
*/ */
@ -5687,7 +5687,8 @@ export class ProfileEmployeeController extends Controller {
if (profile.keycloak != null) { if (profile.keycloak != null) {
const delUserKeycloak = await deleteUser(profile.keycloak); const delUserKeycloak = await deleteUser(profile.keycloak);
if (delUserKeycloak) { if (delUserKeycloak) {
profile.keycloak = _null; // Task #228
// profile.keycloak = _null;
profile.roleKeycloaks = []; profile.roleKeycloaks = [];
profile.isActive = false; profile.isActive = false;
} }
@ -6161,7 +6162,7 @@ export class ProfileEmployeeController extends Controller {
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
.where("profile.keycloak IS NULL") .where("profile.isActive = :isActive", { isActive: false })
.andWhere( .andWhere(
new Brackets((qb) => { new Brackets((qb) => {
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` }); qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });

View file

@ -3459,9 +3459,9 @@ export class ProfileEmployeeTempController extends Controller {
} }
/** /**
* API * API
* *
* @summary (ADMIN) * @summary (ADMIN)
* *
* @param {string} id Id * @param {string} id Id
*/ */
@ -3586,7 +3586,8 @@ export class ProfileEmployeeTempController extends Controller {
if (profile.keycloak != null) { if (profile.keycloak != null) {
const delUserKeycloak = await deleteUser(profile.keycloak); const delUserKeycloak = await deleteUser(profile.keycloak);
if (delUserKeycloak) { if (delUserKeycloak) {
profile.keycloak = _null; // Task #228
// profile.keycloak = _null;
profile.roleKeycloaks = []; profile.roleKeycloaks = [];
profile.isActive = false; profile.isActive = false;
} }
@ -3987,7 +3988,7 @@ export class ProfileEmployeeTempController extends Controller {
case "citizenId": case "citizenId":
[findProfile, total] = await this.profileRepo.findAndCount({ [findProfile, total] = await this.profileRepo.findAndCount({
where: { where: {
keycloak: IsNull(), isActive: false,
citizenId: Like(`%${body.keyword}%`), citizenId: Like(`%${body.keyword}%`),
}, },
relations: ["posType", "posLevel", "current_holders"], relations: ["posType", "posLevel", "current_holders"],
@ -3999,7 +4000,7 @@ export class ProfileEmployeeTempController extends Controller {
case "firstname": case "firstname":
[findProfile, total] = await this.profileRepo.findAndCount({ [findProfile, total] = await this.profileRepo.findAndCount({
where: { where: {
keycloak: IsNull(), isActive: false,
firstName: Like(`%${body.keyword}%`), firstName: Like(`%${body.keyword}%`),
}, },
relations: ["posType", "posLevel", "current_holders"], relations: ["posType", "posLevel", "current_holders"],
@ -4011,7 +4012,7 @@ export class ProfileEmployeeTempController extends Controller {
case "lastname": case "lastname":
[findProfile, total] = await this.profileRepo.findAndCount({ [findProfile, total] = await this.profileRepo.findAndCount({
where: { where: {
keycloak: IsNull(), isActive: false,
lastName: Like(`%${body.keyword}%`), lastName: Like(`%${body.keyword}%`),
}, },
relations: ["posType", "posLevel", "current_holders"], relations: ["posType", "posLevel", "current_holders"],
@ -4023,7 +4024,7 @@ export class ProfileEmployeeTempController extends Controller {
default: default:
[findProfile, total] = await this.profileRepo.findAndCount({ [findProfile, total] = await this.profileRepo.findAndCount({
where: { where: {
keycloak: IsNull(), isActive: false,
}, },
relations: ["posType", "posLevel", "current_holders"], relations: ["posType", "posLevel", "current_holders"],
skip, skip,

View file

@ -274,14 +274,16 @@ export class KeycloakController extends Controller {
}); });
if (!profileEmp) { if (!profileEmp) {
} else { } else {
const _null: any = null; // Task #228
profileEmp.keycloak = _null; // const _null: any = null;
// profileEmp.keycloak = _null;
profileEmp.roleKeycloaks = []; profileEmp.roleKeycloaks = [];
await this.profileEmpRepo.save(profileEmp); await this.profileEmpRepo.save(profileEmp);
} }
} else { } else {
const _null: any = null; // Task #228
profile.keycloak = _null; // const _null: any = null;
// profile.keycloak = _null;
profile.roleKeycloaks = []; profile.roleKeycloaks = [];
await this.profileRepo.save(profile); await this.profileRepo.save(profile);
return new HttpSuccess(); return new HttpSuccess();
@ -566,7 +568,8 @@ export class KeycloakController extends Controller {
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
.where("profile.keycloak IS NOT NULL AND profile.keycloak != ''") // .where("profile.keycloak IS NOT NULL AND profile.keycloak != ''")
.where("profile.isActive = :isActive", { isActive: true })
.andWhere(checkChildFromRole) .andWhere(checkChildFromRole)
.andWhere(conditions) .andWhere(conditions)
.andWhere( .andWhere(
@ -609,7 +612,8 @@ export class KeycloakController extends Controller {
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
.where("profileEmployee.keycloak IS NOT NULL AND profileEmployee.keycloak != ''") // .where("profileEmployee.keycloak IS NOT NULL AND profileEmployee.keycloak != ''")
.where("profileEmployee.isActive = :isActive", { isActive: true })
.andWhere(checkChildFromRole) .andWhere(checkChildFromRole)
.andWhere(conditions) .andWhere(conditions)
.andWhere({ employeeClass: "PERM" }) .andWhere({ employeeClass: "PERM" })