From 273b695d072ccee8beafc5ff2452db79643a28da Mon Sep 17 00:00:00 2001 From: Suchin Sapphasitthatha Date: Sun, 8 Dec 2024 07:09:01 +0000 Subject: [PATCH 1/9] add CI --- .onedev-buildspec.yml | 102 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 .onedev-buildspec.yml diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml new file mode 100644 index 00000000..150cb138 --- /dev/null +++ b/.onedev-buildspec.yml @@ -0,0 +1,102 @@ +version: 37 +jobs: +- name: CI for UAT + steps: + - !CheckoutStep + name: checkout code + cloneCredential: !DefaultCredential {} + withLfs: false + withSubmodules: false + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !GenerateChecksumStep + name: generate package checksum + files: package-lock.json yarn.lock + targetFile: checksum + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !SetupCacheStep + name: set up npm cache + key: node_modules_@file:checksum@ + loadKeys: + - node_modules + paths: + - node_modules + uploadStrategy: UPLOAD_IF_NOT_HIT + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !SetBuildVersionStep + name: set build version + buildVersion: '@tag@' + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !CommandStep + name: build & test + runInContainer: true + image: node + interpreter: !DefaultInterpreter + commands: | + npm install + npm run build + useTTY: true + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !BuildImageStep + name: build docker image + dockerfile: ./docker/Dockerfile + output: !RegistryOutput + tags: hrms-git.chin.in.th/bma-hrms/hrms-api-org:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-api-org:latest + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + triggers: + - !TagCreateTrigger + tags: uat-* + branches: main + retryCondition: never + maxRetries: 3 + retryDelay: 30 + timeout: 14400 +- name: CI for PROD + steps: + - !CheckoutStep + name: checkout code + cloneCredential: !DefaultCredential {} + withLfs: false + withSubmodules: false + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !GenerateChecksumStep + name: generate package checksum + files: package-lock.json yarn.lock + targetFile: checksum + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !SetupCacheStep + name: set up npm cache + key: node_modules_@file:checksum@ + loadKeys: + - node_modules + paths: + - node_modules + uploadStrategy: UPLOAD_IF_NOT_HIT + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !SetBuildVersionStep + name: set build version + buildVersion: '@tag@' + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !CommandStep + name: build & test + runInContainer: true + image: node + interpreter: !DefaultInterpreter + commands: | + npm install + npm run build + useTTY: true + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !BuildImageStep + name: build docker image + dockerfile: ./docker/Dockerfile + output: !RegistryOutput + tags: hrms-git.bangkok.go.th/bma-hrms/hrms-api-org:@build_version@ hrms-git.bangkok.go.th/bma-hrms/hrms-api-org:latest + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + triggers: + - !TagCreateTrigger + tags: prod-* + branches: main + retryCondition: never + maxRetries: 3 + retryDelay: 30 + timeout: 14400 From 000d1d62604c9f6d971213cc65c33aa632377d01 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 11 Dec 2024 23:59:49 +0700 Subject: [PATCH 2/9] no message --- .../OrganizationDotnetController.ts | 260 ++++++++++++++++++ src/controllers/WorkflowController.ts | 2 +- 2 files changed, 261 insertions(+), 1 deletion(-) diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index f0b051e1..341d4cc2 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -2619,6 +2619,266 @@ export class OrganizationDotnetController extends Controller { return new HttpSuccess(profile_); } + /** + * 5. เอารายชื่อคนที่มีการ ,map keycloak id แล้ว + * + * @summary 5. เอารายชื่อคนที่มีการ ,map keycloak id แล้ว + * + */ + @Get("keycloak-employee") + async GetProfileWithKeycloakEmployee() { + const profile = await this.profileEmpRepo.find({ + where: { keycloak: Not(IsNull()) || Not("") }, + relations: [ + "posType", + "posLevel", + "current_holders", + "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", + "profileSalary", + ], + order: { + profileSalary: { + order: "DESC", + }, + }, + }); + + const findRevision = await this.orgRevisionRepo.findOne({ + where: { orgRevisionIsCurrent: true }, + }); + + const profile_ = await Promise.all( + profile.map((item: ProfileEmployee) => { + const rootName = + item.current_holders.length == 0 + ? null + : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot + ?.orgRootName; + const shortName = + item.current_holders.length == 0 + ? null + : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != + null + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild3 != null + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild2 != null + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild1 != null + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != + null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgRoot != null + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + : null; + + return { + oc: rootName, + id: item.id, + createdAt: item.createdAt, + createdUserId: item.createdUserId, + lastUpdatedAt: item.lastUpdatedAt, + lastUpdateUserId: item.lastUpdateUserId, + createdFullName: item.createdFullName, + lastUpdateFullName: item.lastUpdateFullName, + avatar: item.avatar, + avatarName: item.avatarName, + rank: item.rank, + prefix: item.prefix, + firstName: item.firstName, + lastName: item.lastName, + citizenId: item.citizenId, + position: item.position, + posLevelId: item.posLevelId, + posTypeId: item.posTypeId, + email: item.email, + phone: item.phone, + keycloak: item.keycloak, + isProbation: item.isProbation, + isLeave: item.isLeave, + leaveReason: item.leaveReason, + dateLeave: item.dateLeave, + dateRetire: item.dateRetire, + dateAppoint: item.dateAppoint, + dateRetireLaw: item.dateRetireLaw, + dateStart: item.dateStart, + govAgeAbsent: item.govAgeAbsent, + govAgePlus: item.govAgePlus, + birthDate: item.birthDate ?? new Date(), + reasonSameDate: item.reasonSameDate, + ethnicity: item.ethnicity, + telephoneNumber: item.telephoneNumber, + nationality: item.nationality, + gender: item.gender, + relationship: item.relationship, + religion: item.religion, + bloodGroup: item.bloodGroup, + registrationAddress: item.registrationAddress, + registrationProvinceId: item.registrationProvinceId, + registrationDistrictId: item.registrationDistrictId, + registrationSubDistrictId: item.registrationSubDistrictId, + registrationZipCode: item.registrationZipCode, + currentAddress: item.currentAddress, + currentProvinceId: item.currentProvinceId, + currentDistrictId: item.currentDistrictId, + currentSubDistrictId: item.currentSubDistrictId, + currentZipCode: item.currentZipCode, + dutyTimeId: item.dutyTimeId, + dutyTimeEffectiveDate: item.dutyTimeEffectiveDate, + positionLevel: item.profileSalary.length > 0 ? item.profileSalary[0].positionLevel : null, + posNo: shortName, + }; + }), + ); + + return new HttpSuccess(profile_); + } + + /** + * 5. เอารายชื่อคนที่มีการ ,map keycloak id แล้ว + * + * @summary 5. เอารายชื่อคนที่มีการ ,map keycloak id แล้ว + * + */ + @Get("keycloak-all-officer") + async GetProfileWithKeycloakAllOfficer() { + const profile = await this.profileRepo.find({ + where: { keycloak: Not(IsNull()) || Not(""), isLeave: false }, + relations: [ + "current_holders", + "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", + ], + }); + + const findRevision = await this.orgRevisionRepo.findOne({ + where: { orgRevisionIsCurrent: true }, + }); + + const profile_ = await Promise.all( + profile.map((item: Profile) => { + const shortName = + item.current_holders.length == 0 + ? null + : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != + null + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild3 != null + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild2 != null + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild1 != null + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != + null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgRoot != null + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + : null; + + return { + id: item.id, + prefix: item.prefix, + firstName: item.firstName, + lastName: item.lastName, + keycloak: item.keycloak, + posNo: shortName, + }; + }), + ); + + return new HttpSuccess(profile_); + } + + /** + * 5. เอารายชื่อคนที่มีการ ,map keycloak id แล้ว + * + * @summary 5. เอารายชื่อคนที่มีการ ,map keycloak id แล้ว + * + */ + @Get("keycloak-all-employee") + async GetProfileWithKeycloakAllEmployee() { + const profile = await this.profileEmpRepo.find({ + where: { keycloak: Not(IsNull()) || Not(""), isLeave: false }, + relations: [ + "current_holders", + "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", + ], + }); + + const findRevision = await this.orgRevisionRepo.findOne({ + where: { orgRevisionIsCurrent: true }, + }); + + const profile_ = await Promise.all( + profile.map((item: ProfileEmployee) => { + const shortName = + item.current_holders.length == 0 + ? null + : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != + null + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild3 != null + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild2 != null + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild1 != null + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != + null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgRoot != null + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + : null; + + return { + id: item.id, + prefix: item.prefix, + firstName: item.firstName, + lastName: item.lastName, + citizenId: item.citizenId, + keycloak: item.keycloak, + posNo: shortName, + }; + }), + ); + + return new HttpSuccess(profile_); + } + /** * 4. API Update รอบการลงเวลา ในตาราง profile * diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index ce6eb50b..5e1d2df7 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -628,7 +628,7 @@ export class WorkflowController extends Controller { if (!state) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลขั้นตอนการอนุมัติ"); if (state.stateUserComments.filter((x) => x.profileId == body.profileId).length > 0) - throw new HttpError(HttpStatus.NOT_FOUND, "มีผู้ใช้งานนี้อยู่แล้ว"); + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่สามารถเลือกซ้ำได้"); const stateUserComment = new StateUserComment(); stateUserComment.order = state.stateUserComments.length + 1; From 38844e1519b331e38f502a8704fa671eba59db15 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 12 Dec 2024 11:18:58 +0700 Subject: [PATCH 3/9] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84?= =?UTF-8?q?=E0=B8=82=E0=B8=84=E0=B9=89=E0=B8=99=E0=B8=AB=E0=B8=B2=20issue?= =?UTF-8?q?=20#848,=20#850?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/OrganizationController.ts | 70 +++++++-- src/controllers/PositionController.ts | 179 +++++++++++++++------- 2 files changed, 185 insertions(+), 64 deletions(-) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 392f4310..ab75ba6c 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -6372,7 +6372,9 @@ export class OrganizationController extends Controller { orgRoot.orgRootCode + orgChild1.orgChild1Code + " " + - orgChild1.orgChild1ShortName, + orgChild1.orgChild1ShortName + + "/" + + orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName, totalPosition: await this.posMasterRepository.count({ where: { orgRevisionId: orgRoot.orgRevisionId, orgChild1Id: orgChild1.id }, }), @@ -6487,7 +6489,16 @@ export class OrganizationController extends Controller { orgRoot.orgRootCode + orgChild2.orgChild2Code + " " + - orgChild2.orgChild2ShortName, + orgChild2.orgChild2ShortName + + "/" + + orgChild1.orgChild1Name + + " " + + orgRoot.orgRootCode + + orgChild1.orgChild1Code + + " " + + orgChild1.orgChild1ShortName + + "/" + + orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName, totalPosition: await this.posMasterRepository.count({ where: { orgRevisionId: orgRoot.orgRevisionId, @@ -6599,13 +6610,29 @@ export class OrganizationController extends Controller { orgRevisionId: orgRoot.orgRevisionId, orgRootName: orgRoot.orgRootName, responsibility: orgChild3.responsibility, - labelName: - orgChild3.orgChild3Name + - " " + - orgRoot.orgRootCode + - orgChild3.orgChild3Code + - " " + - orgChild3.orgChild3ShortName, + labelName: + orgChild3.orgChild3Name + + " " + + orgRoot.orgRootCode + + orgChild3.orgChild3Code + + " " + + orgChild3.orgChild3ShortName + + "/" + + orgChild2.orgChild2Name + + " " + + orgRoot.orgRootCode + + orgChild2.orgChild2Code + + " " + + orgChild2.orgChild2ShortName + + "/" + + orgChild1.orgChild1Name + + " " + + orgRoot.orgRootCode + + orgChild1.orgChild1Code + + " " + + orgChild1.orgChild1ShortName + + "/" + + orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName, totalPosition: await this.posMasterRepository.count({ where: { orgRevisionId: orgRoot.orgRevisionId, @@ -6723,7 +6750,30 @@ export class OrganizationController extends Controller { orgRoot.orgRootCode + orgChild4.orgChild4Code + " " + - orgChild4.orgChild4ShortName, + orgChild4.orgChild4ShortName + + "/" + + orgChild3.orgChild3Name + + " " + + orgRoot.orgRootCode + + orgChild3.orgChild3Code + + " " + + orgChild3.orgChild3ShortName + + "/" + + orgChild2.orgChild2Name + + " " + + orgRoot.orgRootCode + + orgChild2.orgChild2Code + + " " + + orgChild2.orgChild2ShortName + + "/" + + orgChild1.orgChild1Name + + " " + + orgRoot.orgRootCode + + orgChild1.orgChild1Code + + " " + + orgChild1.orgChild1ShortName + + "/" + + orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName, totalPosition: await this.posMasterRepository.count({ where: { orgRevisionId: orgRoot.orgRevisionId, diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 0cd1fc9b..ac9648ab 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -4953,6 +4953,7 @@ export class PositionController extends Controller { (masterId.length > 0 ? { id: In(masterId) } : { posMasterNo: Like(`%${body.keyword}%`) })), + current_holderId: IsNull(), }, ]; let [posMaster, total] = await AppDataSource.getRepository(PosMaster) @@ -4962,66 +4963,136 @@ export class PositionController extends Controller { .leftJoinAndSelect("posMaster.orgChild2", "orgChild2") .leftJoinAndSelect("posMaster.orgChild3", "orgChild3") .leftJoinAndSelect("posMaster.orgChild4", "orgChild4") + .leftJoinAndSelect("posMaster.orgRevision", "orgRevision") + .leftJoinAndSelect("posMaster.current_holder", "current_holder") + .leftJoinAndSelect("current_holder.posType", "posType") + .leftJoinAndSelect("current_holder.posLevel", "posLevel") .where(conditions) - .andWhere({ - current_holderId: IsNull(), - }) - .andWhere( - _data.root != undefined && _data.root != null - ? _data.root[0] != null - ? `posMaster.orgRootId IN (:...root)` - : `posMaster.orgRootId is null` - : "1=1", - { - root: _data.root, - }, + .orWhere( + new Brackets((qb) => { + qb.andWhere( + _data.root != undefined && _data.root != null + ? _data.root[0] != null + ? `posMaster.orgRootId IN (:...root)` + : `posMaster.orgRootId is null` + : "1=1", + { + root: _data.root, + }, + ) + .andWhere(conditions) + }), ) - .andWhere( - _data.child1 != undefined && _data.child1 != null - ? _data.child1[0] != null - ? `posMaster.orgChild1Id IN (:...child1)` - : `posMaster.orgChild1Id is null` - : "1=1", - { - child1: _data.child1, - }, + .orWhere( + new Brackets((qb) => { + qb.andWhere( + _data.child1 != undefined && _data.child1 != null + ? _data.child1[0] != null + ? `posMaster.orgChild1Id IN (:...child1)` + : `posMaster.orgChild1Id is null` + : "1=1", + { + child1: _data.child1, + }, + ) + .andWhere(conditions) + }), ) - .andWhere( - _data.child2 != undefined && _data.child2 != null - ? _data.child2[0] != null - ? `posMaster.orgChild2Id IN (:...child2)` - : `posMaster.orgChild2Id is null` - : "1=1", - { - child2: _data.child2, - }, + .orWhere( + new Brackets((qb) => { + qb.andWhere( + _data.child2 != undefined && _data.child2 != null + ? _data.child2[0] != null + ? `posMaster.orgChild2Id IN (:...child2)` + : `posMaster.orgChild2Id is null` + : "1=1", + { + child2: _data.child2, + }, + ) + .andWhere(conditions) + }), ) - .andWhere( - _data.child3 != undefined && _data.child3 != null - ? _data.child3[0] != null - ? `posMaster.orgChild3Id IN (:...child3)` - : `posMaster.orgChild3Id is null` - : "1=1", - { - child3: _data.child3, - }, + .orWhere( + new Brackets((qb) => { + qb.andWhere( + _data.child3 != undefined && _data.child3 != null + ? _data.child3[0] != null + ? `posMaster.orgChild3Id IN (:...child3)` + : `posMaster.orgChild3Id is null` + : "1=1", + { + child3: _data.child3, + }, + ) + .andWhere(conditions) + }), ) - .andWhere( - _data.child4 != undefined && _data.child4 != null - ? _data.child4[0] != null - ? `posMaster.orgChild4Id IN (:...child4)` - : `posMaster.orgChild4Id is null` - : "1=1", - { - child4: _data.child4, - }, + .orWhere( + new Brackets((qb) => { + qb.andWhere( + _data.child4 != undefined && _data.child4 != null + ? _data.child4[0] != null + ? `posMaster.orgChild4Id IN (:...child4)` + : `posMaster.orgChild4Id is null` + : "1=1", + { + child4: _data.child4, + }, + ) + .andWhere(conditions) + }), ) - .andWhere( - body.keyword != null && body.keyword != "" - ? body.isAll == false - ? searchShortName - : `CASE WHEN posMaster.orgChild1 is null THEN ${searchShortName0} WHEN posMaster.orgChild2 is null THEN ${searchShortName1} WHEN posMaster.orgChild3 is null THEN ${searchShortName2} WHEN posMaster.orgChild4 is null THEN ${searchShortName3} ELSE ${searchShortName4} END LIKE '%${body.keyword}%'` - : "1=1", + .orWhere( + new Brackets((qb) => { + qb.andWhere( + body.keyword != null && body.keyword != "" + ? `current_holder.posType LIKE :keyword` + : "1=1", + { + keyword: `%${body.keyword}%`, + }, + ) + .andWhere(conditions) + }), + ) + .orWhere( + new Brackets((qb) => { + qb.andWhere( + body.keyword != null && body.keyword != "" + ? `current_holder.posLevel LIKE :keyword` + : "1=1", + { + keyword: `%${body.keyword}%`, + }, + ) + .andWhere(conditions) + }), + ) + .orWhere( + new Brackets((qb) => { + qb.andWhere( + body.keyword != null && body.keyword != "" + ? `current_holder.position LIKE :keyword` + : "1=1", + { + keyword: `%${body.keyword}%`, + }, + ) + .andWhere(conditions) + }), + ) + .orWhere( + new Brackets((qb) => { + qb.andWhere( + body.keyword != null && body.keyword != "" + ? body.isAll == false + ? searchShortName + : `CASE WHEN posMaster.orgChild1 is null THEN ${searchShortName0} WHEN posMaster.orgChild2 is null THEN ${searchShortName1} WHEN posMaster.orgChild3 is null THEN ${searchShortName2} WHEN posMaster.orgChild4 is null THEN ${searchShortName3} ELSE ${searchShortName4} END LIKE '%${body.keyword}%'` + : "1=1", + ) + .andWhere(conditions) + }), ) .orderBy("posMaster.posMasterOrder", "ASC") .skip((body.page - 1) * body.pageSize) From 9abdeca45b60bf6fa4642fb9aadbd27dd69f12bd Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 12 Dec 2024 11:36:11 +0700 Subject: [PATCH 4/9] no message --- src/controllers/CommandController.ts | 196 +++++++++--------- src/controllers/LoginController.ts | 2 +- src/controllers/ProfileController.ts | 164 ++++++++------- src/controllers/ProfileEmployeeController.ts | 10 +- .../ProfileEmployeeTempController.ts | 6 +- 5 files changed, 197 insertions(+), 181 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 26c58100..810d8999 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -700,10 +700,10 @@ export class CommandController extends Controller { commandSend.lastUpdateFullName = request.user.name; commandSend.lastUpdatedAt = new Date(); await this.commandSendRepository.save(commandSend); - if(commandSend && commandSend.id) { + if (commandSend && commandSend.id) { let _ccName = new Array("EMAIL", "INBOX"); let _dataSendCC = new Array(); - for(let i=0; i<_ccName.length; i++) { + for (let i = 0; i < _ccName.length; i++) { _dataSendCC.push({ commandSendId: commandSend.id, name: _ccName[i], @@ -943,7 +943,7 @@ export class CommandController extends Controller { await new permission().PermissionGet(request, "COMMAND"); const command = await this.commandRepository.findOne({ where: { id }, - relations: ["commandType"] + relations: ["commandType"], }); if (!command) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้"); @@ -1148,88 +1148,88 @@ export class CommandController extends Controller { return new HttpSuccess(); } - /** + /** * API ออกคำสั่ง * * @summary API ออกคำสั่ง * * @param {string} id Id คำสั่ง */ - @Put("testRabbit/{id}") - async testRabbit( - @Path() id: string, - @Body() - requestBody: { sign?: boolean }, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "COMMAND"); - const command = await this.commandRepository.findOne({ - where: { id: id }, - relations: ["commandType", "commandRecives",], - }); - if (!command) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้"); - } - command.isSign = true; - if (command.commandExcecuteDate == null) - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบวันที่คำสั่งมีผล"); + @Put("testRabbit/{id}") + async testRabbit( + @Path() id: string, + @Body() + requestBody: { sign?: boolean }, + @Request() request: RequestWithUser, + ) { + await new permission().PermissionUpdate(request, "COMMAND"); + const command = await this.commandRepository.findOne({ + where: { id: id }, + relations: ["commandType", "commandRecives"], + }); + if (!command) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้"); + } + command.isSign = true; + if (command.commandExcecuteDate == null) + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบวันที่คำสั่งมีผล"); - let profiles = - command && command.commandRecives.length > 0 - ? command.commandRecives - .filter((x) => x.profileId != null) - .map((x) => ({ - receiverUserId: x.profileId, - notiLink: "", - })) - : []; + let profiles = + command && command.commandRecives.length > 0 + ? command.commandRecives + .filter((x) => x.profileId != null) + .map((x) => ({ + receiverUserId: x.profileId, + notiLink: "", + })) + : []; - await new CallAPI() - .PostData(request, "/placement/noti/profiles", { - subject: `${command.issue}`, - body: `${command.issue}`, - receiverUserIds: profiles, - payload: "", //แนบไฟล์ - isSendMail: true, - isSendInbox: true, - isSendNotification: true, - }) - .catch((error) => { - console.error("Error calling API:", error); - }); + await new CallAPI() + .PostData(request, "/placement/noti/profiles", { + subject: `${command.issue}`, + body: `${command.issue}`, + receiverUserIds: profiles, + payload: "", //แนบไฟล์ + isSendMail: true, + isSendInbox: true, + isSendNotification: true, + }) + .catch((error) => { + console.error("Error calling API:", error); + }); + + if ( + new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()) < + new Date( + command.commandExcecuteDate.getFullYear(), + command.commandExcecuteDate.getMonth(), + command.commandExcecuteDate.getDate(), + ) + ) { + command.status = "WAITING"; + command.lastUpdateUserId = request.user.sub; + command.lastUpdateFullName = request.user.name; + command.lastUpdatedAt = new Date(); + await this.commandRepository.save(command); + } else { + const path = commandTypePath(command.commandType.code); + if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); + const msg = { + data: { + id: command.id, + status: "REPORTED", + lastUpdateUserId: request.user.sub, + lastUpdateFullName: request.user.name, + lastUpdatedAt: new Date(), + }, + user: request.user, + token: request.headers["authorization"], + }; + sendToQueue(msg); + } + return new HttpSuccess(); + } - if ( - new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()) < - new Date( - command.commandExcecuteDate.getFullYear(), - command.commandExcecuteDate.getMonth(), - command.commandExcecuteDate.getDate(), - ) - ) { - command.status = "WAITING"; - command.lastUpdateUserId = request.user.sub; - command.lastUpdateFullName = request.user.name; - command.lastUpdatedAt = new Date(); - await this.commandRepository.save(command); - } else { - const path = commandTypePath(command.commandType.code); - if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); - const msg = { - data: { - id: command.id, - status: "REPORTED", - lastUpdateUserId: request.user.sub, - lastUpdateFullName: request.user.name, - lastUpdatedAt: new Date(), - }, - user: request.user, - token: request.headers["authorization"], - }; - sendToQueue(msg); - } - return new HttpSuccess(); - } - async cronjobCommand(@Request() request?: RequestWithUser) { const today = new Date(); today.setUTCHours(0, 0, 0, 0); @@ -1255,7 +1255,7 @@ export class CommandController extends Controller { let _data: any = null; await Promise.all([ await new CallAPI() - .PostDataKeycloak("/realms/bma-ehr/protocol/openid-connect/token", data) + .PostDataKeycloak(`/realms/${process.env.KC_REALM}/protocol/openid-connect/token`, data) .then(async (x) => { _data = x; }) @@ -1635,7 +1635,7 @@ export class CommandController extends Controller { @Request() request: RequestWithUser, ) { let command = new Command(); - let commandCode:string = ""; + let commandCode: string = ""; let null_: any = null; if ( requestBody.commandId != undefined && @@ -1826,10 +1826,10 @@ export class CommandController extends Controller { commandSend.lastUpdateFullName = request.user.name; commandSend.lastUpdatedAt = new Date(); await this.commandSendRepository.save(commandSend); - if(commandSend && commandSend.id) { + if (commandSend && commandSend.id) { let _ccName = new Array("EMAIL", "INBOX"); let _dataSendCC = new Array(); - for(let i=0; i<_ccName.length; i++) { + for (let i = 0; i < _ccName.length; i++) { _dataSendCC.push({ commandSendId: commandSend.id, name: _ccName[i], @@ -1842,7 +1842,7 @@ export class CommandController extends Controller { }); } await this.commandSendCCRepository.save(_dataSendCC); - } + } }), ); @@ -1884,10 +1884,10 @@ export class CommandController extends Controller { commandSend.lastUpdateFullName = request.user.name; commandSend.lastUpdatedAt = new Date(); await this.commandSendRepository.save(commandSend); - if(commandSend && commandSend.id) { + if (commandSend && commandSend.id) { let _ccName = new Array("EMAIL", "INBOX"); let _dataSendCC = new Array(); - for(let i=0; i<_ccName.length; i++) { + for (let i = 0; i < _ccName.length; i++) { _dataSendCC.push({ commandSendId: commandSend.id, name: _ccName[i], @@ -1936,7 +1936,7 @@ export class CommandController extends Controller { ) { await Promise.all( body.data.map(async (item) => { - const profile:any = await this.profileRepository.findOneBy({ id: item.profileId }); + const profile: any = await this.profileRepository.findOneBy({ id: item.profileId }); if (!profile) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้"); } @@ -2058,7 +2058,7 @@ export class CommandController extends Controller { ) { await Promise.all( body.data.map(async (item) => { - const profile:any = await this.profileEmployeeRepository.findOneBy({ id: item.profileId }); + const profile: any = await this.profileEmployeeRepository.findOneBy({ id: item.profileId }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } @@ -2265,16 +2265,22 @@ export class CommandController extends Controller { lastName: profile.lastName, }); // กรณี Keycloak ไม่ถูกลบ ให้ลบซ้ำอีกรอบแล้วสร้างใหม่ และหากยังไม่สามารถลบได้ให้แสดง Error - if (profile.keycloak != null && userKeycloakId && userKeycloakId.errorMessage === "User exists with same username") { + if ( + profile.keycloak != null && + userKeycloakId && + userKeycloakId.errorMessage === "User exists with same username" + ) { const delUserKeycloak = await deleteUser(profile.keycloak); - if(delUserKeycloak) { + if (delUserKeycloak) { userKeycloakId = await createUser(profile.citizenId, profile.citizenId, { firstName: profile.firstName, lastName: profile.lastName, }); - } - else { - throw new HttpError(HttpStatus.BAD_REQUEST, "พบข้อผิดพลาด ไม่สามารถจัดการผู้ใช้งานได้"); + } else { + throw new HttpError( + HttpStatus.BAD_REQUEST, + "พบข้อผิดพลาด ไม่สามารถจัดการผู้ใช้งานได้", + ); } } const list = await getRoles(); @@ -2430,7 +2436,7 @@ export class CommandController extends Controller { ) { await Promise.all( body.data.map(async (item) => { - const profile:any = await this.profileRepository.findOne({ + const profile: any = await this.profileRepository.findOne({ where: { id: item.profileId }, relations: ["roleKeycloaks"], }); @@ -2709,7 +2715,7 @@ export class CommandController extends Controller { const exceptClear = await checkExceptCommandType(String(item.commandId)); if (item.isLeave == true && !exceptClear) { await removeProfileInOrganize(_profile.id, "OFFICER"); - } + } //คำสั่งพักราชการ หรือ ให้ออกจากราชการไว้ก่อน solutionเดิม ให้ disable user ไว้แต่ยังไม่ลบ เปลี่ยนเป็นลบ user ออกเลย else if (item.isLeave == true && exceptClear && _profile.keycloak != null) { // const enableActive = await enableStatus(_profile.keycloak, false); @@ -3161,7 +3167,7 @@ export class CommandController extends Controller { where: { profileId: profile.id }, order: { order: "DESC" }, }); - const profileSal: any = new ProfileSalary(); + const profileSal: any = new ProfileSalary(); Object.assign(profileSal, { ...item.bodySalarys, ...meta }); const salaryHistory = new ProfileSalaryHistory(); Object.assign(salaryHistory, { ...profileSal, id: undefined }); @@ -3792,7 +3798,9 @@ export class CommandController extends Controller { if ( orgRevision != null && !["REPORT", "DONE"].includes( - orgRevision.posMasters.find((x) => x.statusReport === "REPORT" || x.statusReport === "DONE")?.statusReport || "", + orgRevision.posMasters.find( + (x) => x.statusReport === "REPORT" || x.statusReport === "DONE", + )?.statusReport || "", ) ) { await this.orgRevisionRepo.update(orgRevision.id, { diff --git a/src/controllers/LoginController.ts b/src/controllers/LoginController.ts index a8670f0d..b2040bed 100644 --- a/src/controllers/LoginController.ts +++ b/src/controllers/LoginController.ts @@ -37,7 +37,7 @@ export class LoginController extends Controller { let _data: any = null; await Promise.all([ await new CallAPI() - .PostDataKeycloak("/realms/bma-ehr/protocol/openid-connect/token", data) + .PostDataKeycloak(`/realms/${process.env.KC_REALM}/protocol/openid-connect/token`, data) .then(async (x) => { _data = x; }) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 527f7d06..b9f22c49 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -278,7 +278,7 @@ export class ProfileController extends Controller { : "-", ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, educations: Education, - url: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`, + url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_SSO}/assets/avatar_user-89f22423.jpg`, }; return new HttpSuccess({ @@ -715,7 +715,7 @@ export class ProfileController extends Controller { : "", telephone: profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "", - url: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`, + url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_SSO}/assets/avatar_user-89f22423.jpg`, url1: _ImgUrl[0] ? _ImgUrl[0] : null, yearUpload1: profiles.profileAvatars[0] ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[0].createdAt)) @@ -1426,11 +1426,11 @@ export class ProfileController extends Controller { ) .orWhere( body.keyword != null && body.keyword != "" - ? "CONCAT(viewDirectorActing.posType, ' (', viewDirectorActing.posLevel, ')') LIKE :keyword" - : "1=1", - { - keyword: `%${body.keyword}%`, - }, + ? "CONCAT(viewDirectorActing.posType, ' (', viewDirectorActing.posLevel, ')') LIKE :keyword" + : "1=1", + { + keyword: `%${body.keyword}%`, + }, ) .orWhere( body.keyword != null && body.keyword != "" @@ -1511,11 +1511,11 @@ export class ProfileController extends Controller { // ) .orWhere( body.keyword != null && body.keyword != "" - ? "CONCAT(viewDirector.posType, ' (', viewDirector.posLevel, ')') LIKE :keyword" - : "1=1", - { - keyword: `%${body.keyword}%`, - }, + ? "CONCAT(viewDirector.posType, ' (', viewDirector.posLevel, ')') LIKE :keyword" + : "1=1", + { + keyword: `%${body.keyword}%`, + }, ) .orWhere( body.keyword != null && body.keyword != "" @@ -1839,7 +1839,7 @@ export class ProfileController extends Controller { const profile = Object.assign(new Profile(), body); profile.prefixMain = profile.prefix; - profile.prefix = profile.rank && profile.rank.length > 0?profile.rank:profile.prefixMain; + profile.prefix = profile.rank && profile.rank.length > 0 ? profile.rank : profile.prefixMain; profile.isProbation = false; profile.isLeave = false; profile.createdUserId = request.user.sub; @@ -1912,7 +1912,7 @@ export class ProfileController extends Controller { const profile: Profile = Object.assign(new Profile(), body); const _null: any = null; profile.prefixMain = profile.prefix; - profile.prefix = profile.rank && profile.rank.length > 0?profile.rank:profile.prefixMain; + profile.prefix = profile.rank && profile.rank.length > 0 ? profile.rank : profile.prefixMain; profile.dateRetire = body.birthDate == null ? _null : calculateRetireDate(body.birthDate); profile.dateRetireLaw = body.birthDate == null ? _null : calculateRetireLaw(body.birthDate); profile.createdUserId = request.user.sub; @@ -1981,7 +1981,7 @@ export class ProfileController extends Controller { } const profile: Profile = Object.assign(new Profile(), body); profile.prefixMain = profile.prefix; - profile.prefix = profile.rank && profile.rank.length > 0?profile.rank:profile.prefixMain; + profile.prefix = profile.rank && profile.rank.length > 0 ? profile.rank : profile.prefixMain; profile.createdUserId = request.user.sub; profile.createdFullName = request.user.name; profile.lastUpdateUserId = request.user.sub; @@ -3553,7 +3553,7 @@ export class ProfileController extends Controller { Object.assign(record, body); record.prefixMain = record.prefix; - record.prefix = record.rank && record.rank.length > 0?record.rank:record.prefixMain; + record.prefix = record.rank && record.rank.length > 0 ? record.rank : record.prefixMain; record.createdUserId = request.user.sub; record.createdFullName = request.user.name; record.createdAt = new Date(); @@ -3804,7 +3804,7 @@ export class ProfileController extends Controller { .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") - .where("current_holders.orgRevisionId = :orgRevisionId", {orgRevisionId: findRevision.id}) + .where("current_holders.orgRevisionId = :orgRevisionId", { orgRevisionId: findRevision.id }) .andWhere( posType != undefined && posType != null && posType != "" ? "posType.posTypeName LIKE :keyword1" @@ -4156,7 +4156,7 @@ export class ProfileController extends Controller { .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") - .where("current_holders.orgRevisionId = :orgRevisionId", {orgRevisionId: findRevision.id}) + .where("current_holders.orgRevisionId = :orgRevisionId", { orgRevisionId: findRevision.id }) .andWhere( _data.root != undefined && _data.root != null ? _data.root[0] != null @@ -4236,20 +4236,20 @@ export class ProfileController extends Controller { : "1=1", ) .andWhere(nodeCondition, { - nodeId: nodeId, + nodeId: nodeId, }) .andWhere( new Brackets((qb) => { qb.orWhere( - searchKeyword != undefined && searchKeyword != null && searchKeyword != "" + searchKeyword != undefined && searchKeyword != null && searchKeyword != "" ? queryLike : "1=1", { keyword: `%${searchKeyword}%`, }, - ) - }) + ); + }), ) .orderBy("current_holders.posMasterNo", "ASC") .skip((page - 1) * pageSize) @@ -6004,7 +6004,7 @@ export class ProfileController extends Controller { ) { let findProfile: any; let total: any; - let revision = await this.orgRevisionRepo.findOne({where: { orgRevisionIsCurrent: true }}); + let revision = await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true } }); const skip = (page - 1) * pageSize; const take = pageSize; let queryLike = `CONCAT( @@ -6023,15 +6023,15 @@ export class ProfileController extends Controller { IFNULL(orgRoot.orgRootShortName, ''), IFNULL(current_holders.posMasterNo , '') ) LIKE :keyword`; - + switch (body.fieldName) { case "citizenId": [findProfile, total] = await this.profileRepo.findAndCount({ - where: { + where: { citizenId: Like(`%${body.keyword}%`), - current_holders:{ - orgRevisionId:revision?.id - } + current_holders: { + orgRevisionId: revision?.id, + }, }, relations: [ "posType", @@ -6050,29 +6050,33 @@ export class ProfileController extends Controller { break; case "fullName": - [findProfile, total] = await this.profileRepo.createQueryBuilder("profile") - .leftJoinAndSelect("profile.posType", "posType") - .leftJoinAndSelect("profile.posLevel", "posLevel") - .leftJoinAndSelect("profile.current_holders", "current_holders") - .leftJoinAndSelect("current_holders.orgRoot", "orgRoot") - .leftJoinAndSelect("current_holders.orgChild1", "orgChild1") - .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") - .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") - .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") - .where("current_holders.orgRevision = :revisionId", { revisionId: revision?.id }) - .andWhere("CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword", { keyword: `%${body.keyword}%` }) - .skip(skip) - .take(take) - .getManyAndCount(); + [findProfile, total] = await this.profileRepo + .createQueryBuilder("profile") + .leftJoinAndSelect("profile.posType", "posType") + .leftJoinAndSelect("profile.posLevel", "posLevel") + .leftJoinAndSelect("profile.current_holders", "current_holders") + .leftJoinAndSelect("current_holders.orgRoot", "orgRoot") + .leftJoinAndSelect("current_holders.orgChild1", "orgChild1") + .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") + .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") + .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") + .where("current_holders.orgRevision = :revisionId", { revisionId: revision?.id }) + .andWhere( + "CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword", + { keyword: `%${body.keyword}%` }, + ) + .skip(skip) + .take(take) + .getManyAndCount(); break; case "position": [findProfile, total] = await this.profileRepo.findAndCount({ - where: { + where: { position: Like(`%${body.keyword}%`), - current_holders:{ - orgRevisionId:revision?.id - } + current_holders: { + orgRevisionId: revision?.id, + }, }, relations: [ "posType", @@ -6091,7 +6095,8 @@ export class ProfileController extends Controller { break; case "posNo": - [findProfile, total] = await this.profileRepo.createQueryBuilder("profile") + [findProfile, total] = await this.profileRepo + .createQueryBuilder("profile") .leftJoinAndSelect("profile.posType", "posType") .leftJoinAndSelect("profile.posLevel", "posLevel") .leftJoinAndSelect("profile.current_holders", "current_holders") @@ -6103,13 +6108,15 @@ export class ProfileController extends Controller { .where("current_holders.orgRevision = :revisionId", { revisionId: revision?.id }) .andWhere( new Brackets((qb) => { - qb.orWhere(body.keyword != undefined && body.keyword != null && body.keyword != "" - ? queryLike - : "1=1", - { - keyword: `%${body.keyword}%`, - }) - }) + qb.orWhere( + body.keyword != undefined && body.keyword != null && body.keyword != "" + ? queryLike + : "1=1", + { + keyword: `%${body.keyword}%`, + }, + ); + }), ) .skip(skip) .take(take) @@ -6118,13 +6125,13 @@ export class ProfileController extends Controller { case "posType": [findProfile, total] = await this.profileRepo.findAndCount({ - where: { + where: { posType: { - posTypeName:Like(`%${body.keyword}%`) + posTypeName: Like(`%${body.keyword}%`), + }, + current_holders: { + orgRevisionId: revision?.id, }, - current_holders:{ - orgRevisionId:revision?.id - } }, relations: [ "posType", @@ -6144,13 +6151,13 @@ export class ProfileController extends Controller { case "posLevel": [findProfile, total] = await this.profileRepo.findAndCount({ - where: { + where: { posLevel: { - posLevelName:Like(`%${body.keyword}%`) + posLevelName: Like(`%${body.keyword}%`), + }, + current_holders: { + orgRevisionId: revision?.id, }, - current_holders:{ - orgRevisionId:revision?.id - } }, relations: [ "posType", @@ -6170,13 +6177,14 @@ export class ProfileController extends Controller { case "organization": [findProfile, total] = await this.profileRepo.findAndCount({ - where: { - current_holders:{ - orgRevisionId:revision?.id, - orgRoot:{ - orgRootName:Like(`%${body.keyword}%`) - } - }}, + where: { + current_holders: { + orgRevisionId: revision?.id, + orgRoot: { + orgRootName: Like(`%${body.keyword}%`), + }, + }, + }, relations: [ "posType", "posLevel", @@ -6192,13 +6200,13 @@ export class ProfileController extends Controller { take, }); break; - + default: [findProfile, total] = await this.profileRepo.findAndCount({ - where:{ - current_holders:{ - orgRevisionId:revision?.id - } + where: { + current_holders: { + orgRevisionId: revision?.id, + }, }, relations: [ "posType", @@ -7251,7 +7259,7 @@ export class ProfileController extends Controller { // item.current_holder == null || item.current_holder.profileSalary.length == 0 // ? null // : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; - const amount = item.current_holder?item.current_holder.amount:null; + const amount = item.current_holder ? item.current_holder.amount : null; let datePeriodStart = new Date( `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, ); @@ -8061,7 +8069,7 @@ export class ProfileController extends Controller { } profile.prefixMain = profile.prefix; - profile.prefix = profile.rank && profile.rank.length > 0?profile.rank:profile.prefixMain; + profile.prefix = profile.rank && profile.rank.length > 0 ? profile.rank : profile.prefixMain; profile.createdUserId = request.user.sub; profile.createdFullName = request.user.name; profile.lastUpdateUserId = request.user.sub; diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 006eb088..4d88cbd1 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -284,7 +284,7 @@ export class ProfileEmployeeController extends Controller { : "-", ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, educations: Education, - url: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`, + url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_SSO}/assets/avatar_user-89f22423.jpg`, }; return new HttpSuccess({ @@ -722,7 +722,7 @@ export class ProfileEmployeeController extends Controller { : "", telephone: profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "", - url: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`, + url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_SSO}/assets/avatar_user-89f22423.jpg`, url1: _ImgUrl[0] ? _ImgUrl[0] : null, yearUpload1: profiles.profileAvatars[0] ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[0].createdAt)) @@ -830,7 +830,7 @@ export class ProfileEmployeeController extends Controller { const profile = Object.assign(new ProfileEmployee(), body); profile.prefixMain = profile.prefix; - profile.prefix = profile.rank && profile.rank.length > 0?profile.rank:profile.prefixMain; + profile.prefix = profile.rank && profile.rank.length > 0 ? profile.rank : profile.prefixMain; profile.createdUserId = request.user.sub; profile.createdFullName = request.user.name; profile.lastUpdateUserId = request.user.sub; @@ -927,7 +927,7 @@ export class ProfileEmployeeController extends Controller { Object.assign(record, body); record.prefixMain = record.prefix; - record.prefix = record.rank && record.rank.length > 0?record.rank:record.prefixMain; + record.prefix = record.rank && record.rank.length > 0 ? record.rank : record.prefixMain; record.createdUserId = request.user.sub; record.createdFullName = request.user.name; record.createdAt = new Date(); @@ -2954,7 +2954,7 @@ export class ProfileEmployeeController extends Controller { // item.current_holder == null || item.current_holder.profileSalary.length == 0 // ? null // : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; - const amount = item.current_holder?item.current_holder.amount:null; + const amount = item.current_holder ? item.current_holder.amount : null; let datePeriodStart = new Date( `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, ); diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index d608d753..eb707207 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -281,7 +281,7 @@ export class ProfileEmployeeTempController extends Controller { : "-", ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, educations: Education, - url: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`, + url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_SSO}/assets/avatar_user-89f22423.jpg`, }; return new HttpSuccess({ @@ -719,7 +719,7 @@ export class ProfileEmployeeTempController extends Controller { : "", telephone: profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "", - url: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`, + url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_SSO}/assets/avatar_user-89f22423.jpg`, url1: _ImgUrl[0] ? _ImgUrl[0] : null, yearUpload1: profiles.profileAvatars[0] ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[0].createdAt)) @@ -2703,7 +2703,7 @@ export class ProfileEmployeeTempController extends Controller { // item.current_holder == null || item.current_holder.profileSalary.length == 0 // ? null // : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; - const amount = item.current_holder?item.current_holder.amount:null; + const amount = item.current_holder ? item.current_holder.amount : null; let datePeriodStart = new Date( `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, ); From 1f0c6cb192132ac2d43a5a08b37ea5c9fd38a387 Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 12 Dec 2024 15:21:55 +0700 Subject: [PATCH 5/9] find profile by nodeId --- .../OrganizationDotnetController.ts | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index 341d4cc2..c7e3bfd9 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -2752,8 +2752,15 @@ export class OrganizationDotnetController extends Controller { * @summary 5. เอารายชื่อคนที่มีการ ,map keycloak id แล้ว * */ - @Get("keycloak-all-officer") - async GetProfileWithKeycloakAllOfficer() { + @Post("keycloak-all-officer") + async PostProfileWithKeycloakAllOfficer( + @Request() req: RequestWithUser, + @Body() + body: { + node: string; + nodeId: string; + }, + ) { const profile = await this.profileRepo.find({ where: { keycloak: Not(IsNull()) || Not(""), isLeave: false }, relations: [ @@ -2818,8 +2825,15 @@ export class OrganizationDotnetController extends Controller { * @summary 5. เอารายชื่อคนที่มีการ ,map keycloak id แล้ว * */ - @Get("keycloak-all-employee") - async GetProfileWithKeycloakAllEmployee() { + @Post("keycloak-all-employee") + async PostProfileWithKeycloakAllEmployee( + @Request() req: RequestWithUser, + @Body() + body: { + node: string; + nodeId: string; + }, + ) { const profile = await this.profileEmpRepo.find({ where: { keycloak: Not(IsNull()) || Not(""), isLeave: false }, relations: [ From 942c88a9610c23348bdbde79333e101b5a4418eb Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 12 Dec 2024 16:32:31 +0700 Subject: [PATCH 6/9] fix issue #848 & #850 --- src/controllers/OrganizationController.ts | 116 ++++++++++++++++++++-- src/controllers/PositionController.ts | 103 ++++--------------- 2 files changed, 129 insertions(+), 90 deletions(-) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index ab75ba6c..a8b65973 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -2663,7 +2663,9 @@ export class OrganizationController extends Controller { orgRoot.orgRootCode + orgChild1.orgChild1Code + " " + - orgChild1.orgChild1ShortName, + orgChild1.orgChild1ShortName + + "/" + + orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName, totalPosition: await this.posMasterRepository.count({ where: { orgRevisionId: orgRoot.orgRevisionId, orgChild1Id: orgChild1.id }, }), @@ -2778,7 +2780,16 @@ export class OrganizationController extends Controller { orgRoot.orgRootCode + orgChild2.orgChild2Code + " " + - orgChild2.orgChild2ShortName, + orgChild2.orgChild2ShortName + + "/" + + orgChild1.orgChild1Name + + " " + + orgRoot.orgRootCode + + orgChild1.orgChild1Code + + " " + + orgChild1.orgChild1ShortName + + "/" + + orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName, totalPosition: await this.posMasterRepository.count({ where: { orgRevisionId: orgRoot.orgRevisionId, @@ -2896,7 +2907,23 @@ export class OrganizationController extends Controller { orgRoot.orgRootCode + orgChild3.orgChild3Code + " " + - orgChild3.orgChild3ShortName, + orgChild3.orgChild3ShortName + + "/" + + orgChild2.orgChild2Name + + " " + + orgRoot.orgRootCode + + orgChild2.orgChild2Code + + " " + + orgChild2.orgChild2ShortName + + "/" + + orgChild1.orgChild1Name + + " " + + orgRoot.orgRootCode + + orgChild1.orgChild1Code + + " " + + orgChild1.orgChild1ShortName + + "/" + + orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName, totalPosition: await this.posMasterRepository.count({ where: { orgRevisionId: orgRoot.orgRevisionId, @@ -3014,7 +3041,30 @@ export class OrganizationController extends Controller { orgRoot.orgRootCode + orgChild4.orgChild4Code + " " + - orgChild4.orgChild4ShortName, + orgChild4.orgChild4ShortName + + "/" + + orgChild3.orgChild3Name + + " " + + orgRoot.orgRootCode + + orgChild3.orgChild3Code + + " " + + orgChild3.orgChild3ShortName + + "/" + + orgChild2.orgChild2Name + + " " + + orgRoot.orgRootCode + + orgChild2.orgChild2Code + + " " + + orgChild2.orgChild2ShortName + + "/" + + orgChild1.orgChild1Name + + " " + + orgRoot.orgRootCode + + orgChild1.orgChild1Code + + " " + + orgChild1.orgChild1ShortName + + "/" + + orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName, totalPosition: await this.posMasterRepository.count({ where: { orgRevisionId: orgRoot.orgRevisionId, @@ -5844,7 +5894,9 @@ export class OrganizationController extends Controller { orgRoot.orgRootCode + orgChild1.orgChild1Code + " " + - orgChild1.orgChild1ShortName, + orgChild1.orgChild1ShortName + + "/" + + orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName, posMaster: await Promise.all( orgChild1.posMasters .filter( @@ -5885,7 +5937,16 @@ export class OrganizationController extends Controller { orgRoot.orgRootCode + orgChild2.orgChild2Code + " " + - orgChild2.orgChild2ShortName, + orgChild2.orgChild2ShortName + + "/" + + orgChild1.orgChild1Name + + " " + + orgRoot.orgRootCode + + orgChild1.orgChild1Code + + " " + + orgChild1.orgChild1ShortName + + "/" + + orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName, posMaster: await Promise.all( orgChild2.posMasters .filter( @@ -5926,7 +5987,23 @@ export class OrganizationController extends Controller { orgRoot.orgRootCode + orgChild3.orgChild3Code + " " + - orgChild3.orgChild3ShortName, + orgChild3.orgChild3ShortName + + "/" + + orgChild2.orgChild2Name + + " " + + orgRoot.orgRootCode + + orgChild2.orgChild2Code + + " " + + orgChild2.orgChild2ShortName + + "/" + + orgChild1.orgChild1Name + + " " + + orgRoot.orgRootCode + + orgChild1.orgChild1Code + + " " + + orgChild1.orgChild1ShortName + + "/" + + orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName, posMaster: await Promise.all( orgChild3.posMasters .filter( @@ -5967,7 +6044,30 @@ export class OrganizationController extends Controller { orgRoot.orgRootCode + orgChild4.orgChild4Code + " " + - orgChild4.orgChild4ShortName, + orgChild4.orgChild4ShortName + + "/" + + orgChild3.orgChild3Name + + " " + + orgRoot.orgRootCode + + orgChild3.orgChild3Code + + " " + + orgChild3.orgChild3ShortName + + "/" + + orgChild2.orgChild2Name + + " " + + orgRoot.orgRootCode + + orgChild2.orgChild2Code + + " " + + orgChild2.orgChild2ShortName + + "/" + + orgChild1.orgChild1Name + + " " + + orgRoot.orgRootCode + + orgChild1.orgChild1Code + + " " + + orgChild1.orgChild1ShortName + + "/" + + orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName, posMaster: await Promise.all( orgChild4.posMasters .filter( diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index ac9648ab..911bf9a6 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -4968,10 +4968,8 @@ export class PositionController extends Controller { .leftJoinAndSelect("current_holder.posType", "posType") .leftJoinAndSelect("current_holder.posLevel", "posLevel") .where(conditions) - .orWhere( - new Brackets((qb) => { - qb.andWhere( - _data.root != undefined && _data.root != null + .andWhere( + _data.root != undefined && _data.root != null ? _data.root[0] != null ? `posMaster.orgRootId IN (:...root)` : `posMaster.orgRootId is null` @@ -4979,14 +4977,9 @@ export class PositionController extends Controller { { root: _data.root, }, - ) - .andWhere(conditions) - }), ) - .orWhere( - new Brackets((qb) => { - qb.andWhere( - _data.child1 != undefined && _data.child1 != null + .andWhere( + _data.child1 != undefined && _data.child1 != null ? _data.child1[0] != null ? `posMaster.orgChild1Id IN (:...child1)` : `posMaster.orgChild1Id is null` @@ -4994,14 +4987,9 @@ export class PositionController extends Controller { { child1: _data.child1, }, - ) - .andWhere(conditions) - }), ) - .orWhere( - new Brackets((qb) => { - qb.andWhere( - _data.child2 != undefined && _data.child2 != null + .andWhere( + _data.child2 != undefined && _data.child2 != null ? _data.child2[0] != null ? `posMaster.orgChild2Id IN (:...child2)` : `posMaster.orgChild2Id is null` @@ -5009,29 +4997,19 @@ export class PositionController extends Controller { { child2: _data.child2, }, - ) - .andWhere(conditions) - }), ) - .orWhere( - new Brackets((qb) => { - qb.andWhere( - _data.child3 != undefined && _data.child3 != null - ? _data.child3[0] != null - ? `posMaster.orgChild3Id IN (:...child3)` - : `posMaster.orgChild3Id is null` - : "1=1", - { - child3: _data.child3, - }, - ) - .andWhere(conditions) - }), + .andWhere( + _data.child3 != undefined && _data.child3 != null + ? _data.child3[0] != null + ? `posMaster.orgChild3Id IN (:...child3)` + : `posMaster.orgChild3Id is null` + : "1=1", + { + child3: _data.child3, + }, ) - .orWhere( - new Brackets((qb) => { - qb.andWhere( - _data.child4 != undefined && _data.child4 != null + .andWhere( + _data.child4 != undefined && _data.child4 != null ? _data.child4[0] != null ? `posMaster.orgChild4Id IN (:...child4)` : `posMaster.orgChild4Id is null` @@ -5039,48 +5017,6 @@ export class PositionController extends Controller { { child4: _data.child4, }, - ) - .andWhere(conditions) - }), - ) - .orWhere( - new Brackets((qb) => { - qb.andWhere( - body.keyword != null && body.keyword != "" - ? `current_holder.posType LIKE :keyword` - : "1=1", - { - keyword: `%${body.keyword}%`, - }, - ) - .andWhere(conditions) - }), - ) - .orWhere( - new Brackets((qb) => { - qb.andWhere( - body.keyword != null && body.keyword != "" - ? `current_holder.posLevel LIKE :keyword` - : "1=1", - { - keyword: `%${body.keyword}%`, - }, - ) - .andWhere(conditions) - }), - ) - .orWhere( - new Brackets((qb) => { - qb.andWhere( - body.keyword != null && body.keyword != "" - ? `current_holder.position LIKE :keyword` - : "1=1", - { - keyword: `%${body.keyword}%`, - }, - ) - .andWhere(conditions) - }), ) .orWhere( new Brackets((qb) => { @@ -5091,7 +5027,10 @@ export class PositionController extends Controller { : `CASE WHEN posMaster.orgChild1 is null THEN ${searchShortName0} WHEN posMaster.orgChild2 is null THEN ${searchShortName1} WHEN posMaster.orgChild3 is null THEN ${searchShortName2} WHEN posMaster.orgChild4 is null THEN ${searchShortName3} ELSE ${searchShortName4} END LIKE '%${body.keyword}%'` : "1=1", ) - .andWhere(conditions) + .andWhere(checkChildConditions) + .andWhere(typeCondition) + .andWhere(revisionCondition) + .andWhere({ current_holderId: IsNull() }); }), ) .orderBy("posMaster.posMasterOrder", "ASC") From 6768a265dea93de25edadd2c9efc146c05ac18b6 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 12 Dec 2024 17:44:57 +0700 Subject: [PATCH 7/9] =?UTF-8?q?fix=20issue=20#860=20:=20=E0=B8=A3=E0=B8=B0?= =?UTF-8?q?=E0=B8=9A=E0=B8=9A=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A=E0=B8=B5?= =?UTF-8?q?=E0=B8=A2=E0=B8=99=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1?= =?UTF-8?q?=E0=B8=95=E0=B8=B4(=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88?= =?UTF-8?q?=E0=B9=89=E0=B8=B2=E0=B8=87)=20=E0=B9=80=E0=B8=82=E0=B9=89?= =?UTF-8?q?=E0=B8=B2=E0=B9=81=E0=B8=97=E0=B9=87=E0=B8=9A=E0=B9=80=E0=B8=A1?= =?UTF-8?q?=E0=B8=99=E0=B8=B9=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1=E0=B8=B9?= =?UTF-8?q?=E0=B8=A5=E0=B8=82=E0=B9=89=E0=B8=B2=E0=B8=A3=E0=B8=B2=E0=B8=8A?= =?UTF-8?q?=E0=B8=81=E0=B8=B2=E0=B8=A3=20Error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 1 + src/interfaces/utils.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 810d8999..3471339e 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -3474,6 +3474,7 @@ export class CommandController extends Controller { const _null: any = null; profile.employeeWage = item.amount == null ? _null : item.amount.toString(); profile.dateStart = new Date(); + profile.dateAppoint = new Date(); profile.amount = item.amount == null ? _null : item.amount; profile.amountSpecial = item.amountSpecial == null ? _null : item.amountSpecial; diff --git a/src/interfaces/utils.ts b/src/interfaces/utils.ts index bd664473..0a329890 100644 --- a/src/interfaces/utils.ts +++ b/src/interfaces/utils.ts @@ -92,7 +92,7 @@ export async function calculateGovAge(profileId: string, type: string) { } }) // const firstStartDate = new Date(records[0].date); - const firstStartDate = profile?.dateAppoint; + const firstStartDate = profile?.dateAppoint ? profile?.dateAppoint : new Date(); const firstEndDate = endDateFristRec ? new Date(endDateFristRec.dateGovernment) : new Date(); const { From 5fc17c4808cbb37075b9b4a9fc2591f0cfbdb4e2 Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 12 Dec 2024 18:29:04 +0700 Subject: [PATCH 8/9] no message --- src/controllers/LoginController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/LoginController.ts b/src/controllers/LoginController.ts index b2040bed..12ae4b5c 100644 --- a/src/controllers/LoginController.ts +++ b/src/controllers/LoginController.ts @@ -42,11 +42,11 @@ export class LoginController extends Controller { _data = x; }) .catch(async (x) => { - throw new HttpError(HttpStatus.UNAUTHORIZED, "ชื่อผู้ใช้งานหรือรหัสผ่านไม่ถูกต้อง"); + throw new HttpError(HttpStatus.UNAUTHORIZED, "ชื่อผู้ใช้งานหรือรหัสผ่านไม่ถูกต้อง4"); }), ]); if (_data == null) { - return new HttpError(HttpStatus.UNAUTHORIZED, "ชื่อผู้ใช้งานหรือรหัสผ่านไม่ถูกต้อง"); + return new HttpError(HttpStatus.UNAUTHORIZED, "ชื่อผู้ใช้งานหรือรหัสผ่านไม่ถูกต้อง5"); } else { return new HttpSuccess(_data); } From 971fac10d1687a53eb5bcdc528c827dfb81e9b4e Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 13 Dec 2024 10:25:52 +0700 Subject: [PATCH 9/9] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=AD?= =?UTF-8?q?=E0=B8=99=E0=B8=B8=E0=B8=A1=E0=B8=B1=E0=B8=95=E0=B8=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/OrganizationDotnetController.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index c7e3bfd9..006cf6aa 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -451,6 +451,7 @@ export class OrganizationDotnetController extends Controller { orgRevisionIsCurrent: true, orgRevisionIsDraft: false, }, + isDirector: true, orgRootId: org?.root ?? "", orgChild1Id: IsNull(), orgChild2Id: IsNull(),