From d553c1406c6520b19d64affae3b979d65c40bdee Mon Sep 17 00:00:00 2001 From: harid Date: Wed, 1 Apr 2026 17:50:38 +0700 Subject: [PATCH] =?UTF-8?q?[Fix]=20=E0=B8=81=E0=B8=A3=E0=B8=93=E0=B8=B5?= =?UTF-8?q?=E0=B8=9E=E0=B9=89=E0=B8=99=E0=B8=A3=E0=B8=B2=E0=B8=8A=E0=B8=81?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82?= =?UTF-8?q?=E0=B9=80=E0=B8=9B=E0=B9=87=E0=B8=99=E0=B9=84=E0=B8=A1=E0=B9=88?= =?UTF-8?q?=E0=B8=95=E0=B9=89=E0=B8=AD=E0=B8=87=20clear=20=E0=B8=9F?= =?UTF-8?q?=E0=B8=B4=E0=B8=A5=E0=B8=94=E0=B9=8C=20keycloak=20#228?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 30 ++++++++++++------- src/controllers/ProfileController.ts | 9 +++--- src/controllers/ProfileEmployeeController.ts | 9 +++--- .../ProfileEmployeeTempController.ts | 15 +++++----- src/controllers/UserController.ts | 16 ++++++---- 5 files changed, 48 insertions(+), 31 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 016b4768..2993f480 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1657,7 +1657,8 @@ export class CommandController extends Controller { // console.log("4. disable keycloak/authen") const delUserKeycloak = await deleteUser(_profile.keycloak, adminToken); if (delUserKeycloak) { - _profile.keycloak = ""; + // Task #228 + // _profile.keycloak = ""; _profile.roleKeycloaks = []; } } @@ -1713,7 +1714,8 @@ export class CommandController extends Controller { // disable keycloak/authen const delUserKeycloak = await deleteUser(_profileEmp.keycloak, adminToken); if (delUserKeycloak) { - _profileEmp.keycloak = ""; + // Task #228 + // _profileEmp.keycloak = ""; _profileEmp.roleKeycloaks = []; } } @@ -4128,7 +4130,8 @@ export class CommandController extends Controller { if (profile.keycloak != null) { const delUserKeycloak = await deleteUser(profile.keycloak); if (delUserKeycloak) { - profile.keycloak = _null; + // Task #228 + // profile.keycloak = _null; profile.roleKeycloaks = []; profile.isActive = false; } @@ -4532,7 +4535,8 @@ export class CommandController extends Controller { if (profile.keycloak != null) { const delUserKeycloak = await deleteUser(profile.keycloak); if (delUserKeycloak) { - profile.keycloak = _null; + // Task #228 + // profile.keycloak = _null; profile.roleKeycloaks = []; profile.isActive = false; } @@ -4752,7 +4756,8 @@ export class CommandController extends Controller { if (profile.keycloak != null) { const delUserKeycloak = await deleteUser(profile.keycloak); if (delUserKeycloak) { - profile.keycloak = _null; + // Task #228 + // profile.keycloak = _null; profile.roleKeycloaks = []; profile.isActive = false; } @@ -5248,7 +5253,8 @@ export class CommandController extends Controller { if (_profile.keycloak != null) { const delUserKeycloak = await deleteUser(_profile.keycloak); if (delUserKeycloak) { - _profile.keycloak = _null; + // Task #228 + // _profile.keycloak = _null; _profile.roleKeycloaks = []; _profile.isActive = false; } @@ -5431,7 +5437,8 @@ export class CommandController extends Controller { if (_profile.keycloak != null) { const delUserKeycloak = await deleteUser(_profile.keycloak); if (delUserKeycloak) { - _profile.keycloak = _null; + // Task #228 + // _profile.keycloak = _null; _profile.roleKeycloaks = []; _profile.isActive = false; } @@ -5769,7 +5776,8 @@ export class CommandController extends Controller { if (_profile.keycloak != null) { const delUserKeycloak = await deleteUser(_profile.keycloak); if (delUserKeycloak) { - _profile.keycloak = _null; + // Task #228 + // _profile.keycloak = _null; _profile.roleKeycloaks = []; _profile.isActive = false; } @@ -6206,7 +6214,8 @@ export class CommandController extends Controller { if (_profile.keycloak != null) { const delUserKeycloak = await deleteUser(_profile.keycloak); if (delUserKeycloak) { - _profile.keycloak = _null; + // Task #228 + // _profile.keycloak = _null; _profile.roleKeycloaks = []; _profile.isActive = false; } @@ -6503,7 +6512,8 @@ export class CommandController extends Controller { if (profileEmployee.keycloak != null) { // const delUserKeycloak = await deleteUser(profileEmployee.keycloak); // if (delUserKeycloak) { - profileEmployee.keycloak = _null; + // Task #228 + // profileEmployee.keycloak = _null; profileEmployee.roleKeycloaks = []; profileEmployee.isActive = false; // } diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index b49581d0..18e3f96c 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -11133,9 +11133,9 @@ export class ProfileController extends Controller { } /** - * API อัพเดทเกษียณ + * API อัพเดทถึงแก่กรรม * - * @summary อัพเดทเกษียณ (ADMIN) + * @summary อัพเดทถึงแก่กรรม (ADMIN) * * @param {string} id Id ทะเบียนประวัติ */ @@ -11263,7 +11263,8 @@ export class ProfileController extends Controller { if (profile.keycloak != null) { const delUserKeycloak = await deleteUser(profile.keycloak); if (delUserKeycloak) { - profile.keycloak = _null; + // Task #228 + // profile.keycloak = _null; profile.roleKeycloaks = []; profile.isActive = false; } @@ -11371,7 +11372,7 @@ export class ProfileController extends Controller { .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") - .where("profile.keycloak IS NULL") + .where("profile.isActive = :isActive", { isActive: false }) .andWhere( new Brackets((qb) => { qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` }); diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index a1ac02af..ffdb2085 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -5560,9 +5560,9 @@ export class ProfileEmployeeController extends Controller { } /** - * API อัพเดทเกษียณ + * API อัพเดทถึงแก่กรรม * - * @summary อัพเดทเกษียณ (ADMIN) + * @summary อัพเดทถึงแก่กรรม (ADMIN) * * @param {string} id Id ทะเบียนประวัติ */ @@ -5687,7 +5687,8 @@ export class ProfileEmployeeController extends Controller { if (profile.keycloak != null) { const delUserKeycloak = await deleteUser(profile.keycloak); if (delUserKeycloak) { - profile.keycloak = _null; + // Task #228 + // profile.keycloak = _null; profile.roleKeycloaks = []; profile.isActive = false; } @@ -6161,7 +6162,7 @@ export class ProfileEmployeeController extends Controller { .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") - .where("profile.keycloak IS NULL") + .where("profile.isActive = :isActive", { isActive: false }) .andWhere( new Brackets((qb) => { qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` }); diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 7930b872..a864710d 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -3459,9 +3459,9 @@ export class ProfileEmployeeTempController extends Controller { } /** - * API อัพเดทเกษียณ + * API อัพเดทถึงแก่กรรม * - * @summary อัพเดทเกษียณ (ADMIN) + * @summary อัพเดทถึงแก่กรรม (ADMIN) * * @param {string} id Id ทะเบียนประวัติ */ @@ -3586,7 +3586,8 @@ export class ProfileEmployeeTempController extends Controller { if (profile.keycloak != null) { const delUserKeycloak = await deleteUser(profile.keycloak); if (delUserKeycloak) { - profile.keycloak = _null; + // Task #228 + // profile.keycloak = _null; profile.roleKeycloaks = []; profile.isActive = false; } @@ -3987,7 +3988,7 @@ export class ProfileEmployeeTempController extends Controller { case "citizenId": [findProfile, total] = await this.profileRepo.findAndCount({ where: { - keycloak: IsNull(), + isActive: false, citizenId: Like(`%${body.keyword}%`), }, relations: ["posType", "posLevel", "current_holders"], @@ -3999,7 +4000,7 @@ export class ProfileEmployeeTempController extends Controller { case "firstname": [findProfile, total] = await this.profileRepo.findAndCount({ where: { - keycloak: IsNull(), + isActive: false, firstName: Like(`%${body.keyword}%`), }, relations: ["posType", "posLevel", "current_holders"], @@ -4011,7 +4012,7 @@ export class ProfileEmployeeTempController extends Controller { case "lastname": [findProfile, total] = await this.profileRepo.findAndCount({ where: { - keycloak: IsNull(), + isActive: false, lastName: Like(`%${body.keyword}%`), }, relations: ["posType", "posLevel", "current_holders"], @@ -4023,7 +4024,7 @@ export class ProfileEmployeeTempController extends Controller { default: [findProfile, total] = await this.profileRepo.findAndCount({ where: { - keycloak: IsNull(), + isActive: false, }, relations: ["posType", "posLevel", "current_holders"], skip, diff --git a/src/controllers/UserController.ts b/src/controllers/UserController.ts index 9889bd9b..52b97622 100644 --- a/src/controllers/UserController.ts +++ b/src/controllers/UserController.ts @@ -274,14 +274,16 @@ export class KeycloakController extends Controller { }); if (!profileEmp) { } else { - const _null: any = null; - profileEmp.keycloak = _null; + // Task #228 + // const _null: any = null; + // profileEmp.keycloak = _null; profileEmp.roleKeycloaks = []; await this.profileEmpRepo.save(profileEmp); } } else { - const _null: any = null; - profile.keycloak = _null; + // Task #228 + // const _null: any = null; + // profile.keycloak = _null; profile.roleKeycloaks = []; await this.profileRepo.save(profile); return new HttpSuccess(); @@ -566,7 +568,8 @@ export class KeycloakController extends Controller { .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .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(conditions) .andWhere( @@ -609,7 +612,8 @@ export class KeycloakController extends Controller { .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .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(conditions) .andWhere({ employeeClass: "PERM" })