From 05e56ba91fcb9d3fa89ca7cb55fcc05902657514 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 4 Dec 2024 13:37:22 +0700 Subject: [PATCH 1/7] fix posLevel undefined --- src/controllers/ReportController.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index e8d8214..1fa2f21 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -7075,6 +7075,7 @@ export class ReportController extends Controller { "salaryProfileEmployee.posMasterNo", "salaryProfileEmployee.position", "salaryProfileEmployee.posType", + "salaryProfileEmployee.posTypeShort", "salaryProfileEmployee.posLevel", "salaryProfileEmployee.profileId", "salaryProfileEmployee.prefix", @@ -7089,7 +7090,7 @@ export class ReportController extends Controller { posMasterNo: `${item.orgShortName}${item.posMasterNo}`, positionName: item.position, posType: item.posType, - posLevel: `${item.posTypeShort}${item.posLevel}`, + posLevel: `${item.posTypeShort ?? ""} ${item.posLevel ?? ""}`, profileId: item.profileId, prefix: item.prefix, firstName: item.firstName, @@ -7161,6 +7162,7 @@ export class ReportController extends Controller { "salaryProfileEmployee.posMasterNo", "salaryProfileEmployee.position", "salaryProfileEmployee.posType", + "salaryProfileEmployee.posTypeShort", "salaryProfileEmployee.posLevel", "salaryProfileEmployee.profileId", "salaryProfileEmployee.prefix", @@ -7175,7 +7177,7 @@ export class ReportController extends Controller { posMasterNo: `${item.orgShortName}${item.posMasterNo}`, positionName: item.position, posType: item.posType, - posLevel: `${item.posTypeShort}${item.posLevel}`, + posLevel: `${item.posTypeShort ?? ""} ${item.posLevel ?? ""}`, profileId: item.profileId, prefix: item.prefix, firstName: item.firstName, From f0ed9a61d332ed8ab5c2fd8e77907f2ba3bbefbe Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 6 Dec 2024 15:52:27 +0700 Subject: [PATCH 2/7] add fields for exec --- src/controllers/ReportController.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 1fa2f21..2444339 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -6562,6 +6562,10 @@ export class ReportController extends Controller { firstName: item.firstName, lastName: item.lastName, citizenId: item.citizenId, + amount: item.amount, + amountSpecial: item.amountSpecial, + amountUse: item.amountUse, + positionSalaryAmount: item.positionSalaryAmount, })); return new HttpSuccess(_salaryRank); @@ -6612,6 +6616,10 @@ export class ReportController extends Controller { firstName: item.firstName, lastName: item.lastName, citizenId: item.citizenId, + amount: item.amount, + amountSpecial: item.amountSpecial, + amountUse: item.amountUse, + positionSalaryAmount: item.positionSalaryAmount, })); return new HttpSuccess(_salaryRank); @@ -6656,6 +6664,10 @@ export class ReportController extends Controller { firstName: item.firstName, lastName: item.lastName, citizenId: item.citizenId, + amount: item.amount, + amountSpecial: item.amountSpecial, + amountUse: item.amountUse, + positionSalaryAmount: item.positionSalaryAmount, })); return new HttpSuccess(_salaryRank); @@ -6699,6 +6711,10 @@ export class ReportController extends Controller { firstName: item.firstName, lastName: item.lastName, citizenId: item.citizenId, + amount: item.amount, + amountSpecial: item.amountSpecial, + amountUse: item.amountUse, + positionSalaryAmount: item.positionSalaryAmount, })); return new HttpSuccess(_salaryRank); @@ -6742,6 +6758,10 @@ export class ReportController extends Controller { firstName: item.firstName, lastName: item.lastName, citizenId: item.citizenId, + amount: item.amount, + amountSpecial: item.amountSpecial, + amountUse: item.amountUse, + positionSalaryAmount: item.positionSalaryAmount, })); return new HttpSuccess(_salaryRank); From 4766b0e7e58ac9a932da3541aa438cf7b7a07d4d Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 6 Dec 2024 16:03:45 +0700 Subject: [PATCH 3/7] fix add fields for exec --- src/controllers/ReportController.ts | 60 +++++++++++++++++++---------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 2444339..9d7b065 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -6562,10 +6562,6 @@ export class ReportController extends Controller { firstName: item.firstName, lastName: item.lastName, citizenId: item.citizenId, - amount: item.amount, - amountSpecial: item.amountSpecial, - amountUse: item.amountUse, - positionSalaryAmount: item.positionSalaryAmount, })); return new HttpSuccess(_salaryRank); @@ -6616,10 +6612,6 @@ export class ReportController extends Controller { firstName: item.firstName, lastName: item.lastName, citizenId: item.citizenId, - amount: item.amount, - amountSpecial: item.amountSpecial, - amountUse: item.amountUse, - positionSalaryAmount: item.positionSalaryAmount, })); return new HttpSuccess(_salaryRank); @@ -6664,10 +6656,6 @@ export class ReportController extends Controller { firstName: item.firstName, lastName: item.lastName, citizenId: item.citizenId, - amount: item.amount, - amountSpecial: item.amountSpecial, - amountUse: item.amountUse, - positionSalaryAmount: item.positionSalaryAmount, })); return new HttpSuccess(_salaryRank); @@ -6711,10 +6699,6 @@ export class ReportController extends Controller { firstName: item.firstName, lastName: item.lastName, citizenId: item.citizenId, - amount: item.amount, - amountSpecial: item.amountSpecial, - amountUse: item.amountUse, - positionSalaryAmount: item.positionSalaryAmount, })); return new HttpSuccess(_salaryRank); @@ -6758,10 +6742,6 @@ export class ReportController extends Controller { firstName: item.firstName, lastName: item.lastName, citizenId: item.citizenId, - amount: item.amount, - amountSpecial: item.amountSpecial, - amountUse: item.amountUse, - positionSalaryAmount: item.positionSalaryAmount, })); return new HttpSuccess(_salaryRank); @@ -6834,6 +6814,10 @@ export class ReportController extends Controller { "salaryProfile.firstName", "salaryProfile.lastName", "salaryProfile.citizenId", + "salaryProfile.amount", + "salaryProfile.amountSpecial", + "salaryProfile.amountUse", + "salaryProfile.positionSalaryAmount", ]) .getMany(); @@ -6848,6 +6832,10 @@ export class ReportController extends Controller { firstName: item.firstName, lastName: item.lastName, citizenId: item.citizenId, + amount: item.amount, + amountSpecial: item.amountSpecial, + amountUse: item.amountUse, + positionSalaryAmount: item.positionSalaryAmount, })); return new HttpSuccess(_salaryRank); @@ -6928,6 +6916,10 @@ export class ReportController extends Controller { "salaryProfile.firstName", "salaryProfile.lastName", "salaryProfile.citizenId", + "salaryProfile.amount", + "salaryProfile.amountSpecial", + "salaryProfile.amountUse", + "salaryProfile.positionSalaryAmount", ]) .getMany(); @@ -6942,6 +6934,10 @@ export class ReportController extends Controller { firstName: item.firstName, lastName: item.lastName, citizenId: item.citizenId, + amount: item.amount, + amountSpecial: item.amountSpecial, + amountUse: item.amountUse, + positionSalaryAmount: item.positionSalaryAmount, })); return new HttpSuccess(_salaryRank); @@ -7015,6 +7011,10 @@ export class ReportController extends Controller { "salaryProfile.firstName", "salaryProfile.lastName", "salaryProfile.citizenId", + "salaryProfile.amount", + "salaryProfile.amountSpecial", + "salaryProfile.amountUse", + "salaryProfile.positionSalaryAmount", ]) .getMany(); @@ -7029,6 +7029,10 @@ export class ReportController extends Controller { firstName: item.firstName, lastName: item.lastName, citizenId: item.citizenId, + amount: item.amount, + amountSpecial: item.amountSpecial, + amountUse: item.amountUse, + positionSalaryAmount: item.positionSalaryAmount, })); return new HttpSuccess(_salaryRank); @@ -7102,6 +7106,10 @@ export class ReportController extends Controller { "salaryProfileEmployee.firstName", "salaryProfileEmployee.lastName", "salaryProfileEmployee.citizenId", + "salaryProfileEmployee.amount", + "salaryProfileEmployee.amountSpecial", + "salaryProfileEmployee.amountUse", + "salaryProfileEmployee.positionSalaryAmount", ]) .getMany(); @@ -7116,6 +7124,10 @@ export class ReportController extends Controller { firstName: item.firstName, lastName: item.lastName, citizenId: item.citizenId, + amount: item.amount, + amountSpecial: item.amountSpecial, + amountUse: item.amountUse, + positionSalaryAmount: item.positionSalaryAmount, })); return new HttpSuccess(_salaryRank); @@ -7189,6 +7201,10 @@ export class ReportController extends Controller { "salaryProfileEmployee.firstName", "salaryProfileEmployee.lastName", "salaryProfileEmployee.citizenId", + "salaryProfileEmployee.amount", + "salaryProfileEmployee.amountSpecial", + "salaryProfileEmployee.amountUse", + "salaryProfileEmployee.positionSalaryAmount", ]) .getMany(); @@ -7203,6 +7219,10 @@ export class ReportController extends Controller { firstName: item.firstName, lastName: item.lastName, citizenId: item.citizenId, + amount: item.amount, + amountSpecial: item.amountSpecial, + amountUse: item.amountUse, + positionSalaryAmount: item.positionSalaryAmount, })); return new HttpSuccess(_salaryRank); From 5b1f356e99ca9b4d13d2d23ece021f0f08380d84 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 6 Dec 2024 18:52:28 +0700 Subject: [PATCH 4/7] add field amountSpecial --- src/controllers/ReportController.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 9d7b065..e654d63 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -7455,6 +7455,7 @@ export class ReportController extends Controller { commandYear: number; templateDoc: string | null; amount: Double | null; + amountSpecial: Double | null; positionSalaryAmount: Double | null; mouthSalaryAmount: Double | null; }[]; @@ -7475,6 +7476,7 @@ export class ReportController extends Controller { profileId: salary.profileId, date: new Date(), amount: v.amount, + amountSpecial: v.amountSpecial, commandId: v.commandId, positionSalaryAmount: v.positionSalaryAmount, mouthSalaryAmount: v.mouthSalaryAmount, @@ -7522,6 +7524,7 @@ export class ReportController extends Controller { commandYear: number; templateDoc: string | null; amount: Double | null; + amountSpecial: Double | null; positionSalaryAmount: Double | null; mouthSalaryAmount: Double | null; }[]; From 0d9af75ded8abf5205e51ec7fddd5839bd1b68f8 Mon Sep 17 00:00:00 2001 From: "DESKTOP-2S5P7D1\\Windows 10" Date: Sat, 7 Dec 2024 09:31:11 +0700 Subject: [PATCH 5/7] test build discord --- .github/workflows/release.yaml | 59 ++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index be8eac8..553d7a9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,5 +1,5 @@ -name: release-test -run-name: release-test ${{ github.actor }} +name: release +run-name: release ${{ github.actor }} on: push: tags: @@ -9,11 +9,11 @@ env: REGISTRY: docker.frappet.com IMAGE_NAME: ehr/bma-ehr-salary-service DEPLOY_HOST: frappet.com - # COMPOSE_PATH: /home/frappet/docker/bma-ehr COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-salary + jobs: # act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=version-1.0.36 -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357 - release-test: + release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -67,21 +67,40 @@ jobs: docker compose pull docker compose up -d echo "${{ steps.gen_ver.outputs.image_ver }}"> success - - uses: snow-actions/line-notify@v1.1.0 + - name: Notify Discord Success if: success() - with: - access_token: ${{ secrets.TOKEN_LINE }} - message: | - -Success✅✅✅ - Image: ${{env.IMAGE_NAME}} - Version: ${{ steps.gen_ver.outputs.IMAGE_VER }} - By: ${{github.actor}} - - uses: snow-actions/line-notify@v1.1.0 + run: | + curl -H "Content-Type: application/json" \ + -X POST \ + -d '{ + "embeds": [{ + "title": "✅ Deployment Success!", + "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`", + "color": 3066993, + "footer": { + "text": "Release Notification", + "icon_url": "https://example.com/success-icon.png" + }, + "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" + }] + }' \ + ${{ secrets.DISCORD_WEBHOOK }} + + - name: Notify Discord Failure if: failure() - with: - access_token: ${{ secrets.TOKEN_LINE }} - message: | - -Failure❌❌❌ - Image: ${{env.IMAGE_NAME}} - Version: ${{ steps.gen_ver.outputs.IMAGE_VER }} - By: ${{github.actor}} + run: | + curl -H "Content-Type: application/json" \ + -X POST \ + -d '{ + "embeds": [{ + "title": "❌ Deployment Failed!", + "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`", + "color": 15158332, + "footer": { + "text": "Release Notification", + "icon_url": "https://example.com/failure-icon.png" + }, + "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" + }] + }' \ + ${{ secrets.DISCORD_WEBHOOK }} From 4529ac4f9c34bc17f44044893d8a9714f2505138 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 10 Dec 2024 16:51:39 +0700 Subject: [PATCH 6/7] rename function --- src/controllers/SalaryPeriodEmployeeController.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controllers/SalaryPeriodEmployeeController.ts b/src/controllers/SalaryPeriodEmployeeController.ts index c28390f..5da441f 100644 --- a/src/controllers/SalaryPeriodEmployeeController.ts +++ b/src/controllers/SalaryPeriodEmployeeController.ts @@ -402,7 +402,7 @@ export class SalaryPeriodEmployeeController extends Controller { } let type = salaryProfile.type; - salaryProfile = await this.testza(type, salaryProfile); + salaryProfile = await this.calSalary(type, salaryProfile); salaryProfile.lastUpdateUserId = req.user.sub; salaryProfile.lastUpdateFullName = req.user.name; @@ -725,7 +725,7 @@ export class SalaryPeriodEmployeeController extends Controller { salaryProfile.remark = body.remark == null ? _null : body.remark; let type = salaryProfile.type; - salaryProfile = await this.testza(type, salaryProfile); + salaryProfile = await this.calSalary(type, salaryProfile); salaryProfile.lastUpdateUserId = req.user.sub; salaryProfile.lastUpdateFullName = req.user.name; @@ -1083,7 +1083,7 @@ export class SalaryPeriodEmployeeController extends Controller { } let type = salaryProfile.type; - salaryProfile = await this.testza(type, salaryProfile); + salaryProfile = await this.calSalary(type, salaryProfile); const before = null; salaryProfile.salaryOrgId = salaryOrg.id; @@ -1724,7 +1724,7 @@ export class SalaryPeriodEmployeeController extends Controller { return new HttpSuccess(); } - async testza(type: string, salaryProfile: SalaryProfileEmployee): Promise { + async calSalary(type: string, salaryProfile: SalaryProfileEmployee): Promise { if (type == "NONE") { salaryProfile.isNext = false; salaryProfile.amountSpecial = 0; From 3e576ef9376334473ad526fbe7291964b8902756 Mon Sep 17 00:00:00 2001 From: "DESKTOP-2S5P7D1\\Windows 10" Date: Sat, 14 Dec 2024 01:04:18 +0700 Subject: [PATCH 7/7] edit permission --- src/interfaces/permission.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/interfaces/permission.ts b/src/interfaces/permission.ts index eba3065..9f3ee02 100644 --- a/src/interfaces/permission.ts +++ b/src/interfaces/permission.ts @@ -184,7 +184,7 @@ class CheckAuth { }); } - public async checkOrg(token: any,keycloakId: string) { + public async checkOrg(token: any, keycloakId: string) { const redisClient = await this.redis.createClient({ host: process.env.REDIS_HOST, port: process.env.REDIS_PORT, @@ -195,14 +195,15 @@ class CheckAuth { reply = JSON.parse(reply); } else { try { + if (!keycloakId) throw "Error calling API No KeycloakId"; const x = await new CallAPI().GetData( { headers: { authorization: token }, - }, - `/org/permission/checkOrg/${keycloakId}`, - false + }, + `/org/permission/checkOrg/${keycloakId}`, + false, ); - + const data = { orgRootId: x.orgRootId, orgChild1Id: x.orgChild1Id, @@ -210,7 +211,7 @@ class CheckAuth { orgChild3Id: x.orgChild3Id, orgChild4Id: x.orgChild4Id, }; - + return data; } catch (error) { console.error("Error calling API:", error);