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 }} diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index e8d8214..e654d63 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -6814,6 +6814,10 @@ export class ReportController extends Controller { "salaryProfile.firstName", "salaryProfile.lastName", "salaryProfile.citizenId", + "salaryProfile.amount", + "salaryProfile.amountSpecial", + "salaryProfile.amountUse", + "salaryProfile.positionSalaryAmount", ]) .getMany(); @@ -6828,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); @@ -6908,6 +6916,10 @@ export class ReportController extends Controller { "salaryProfile.firstName", "salaryProfile.lastName", "salaryProfile.citizenId", + "salaryProfile.amount", + "salaryProfile.amountSpecial", + "salaryProfile.amountUse", + "salaryProfile.positionSalaryAmount", ]) .getMany(); @@ -6922,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); @@ -6995,6 +7011,10 @@ export class ReportController extends Controller { "salaryProfile.firstName", "salaryProfile.lastName", "salaryProfile.citizenId", + "salaryProfile.amount", + "salaryProfile.amountSpecial", + "salaryProfile.amountUse", + "salaryProfile.positionSalaryAmount", ]) .getMany(); @@ -7009,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); @@ -7075,12 +7099,17 @@ export class ReportController extends Controller { "salaryProfileEmployee.posMasterNo", "salaryProfileEmployee.position", "salaryProfileEmployee.posType", + "salaryProfileEmployee.posTypeShort", "salaryProfileEmployee.posLevel", "salaryProfileEmployee.profileId", "salaryProfileEmployee.prefix", "salaryProfileEmployee.firstName", "salaryProfileEmployee.lastName", "salaryProfileEmployee.citizenId", + "salaryProfileEmployee.amount", + "salaryProfileEmployee.amountSpecial", + "salaryProfileEmployee.amountUse", + "salaryProfileEmployee.positionSalaryAmount", ]) .getMany(); @@ -7089,12 +7118,16 @@ 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, lastName: item.lastName, citizenId: item.citizenId, + amount: item.amount, + amountSpecial: item.amountSpecial, + amountUse: item.amountUse, + positionSalaryAmount: item.positionSalaryAmount, })); return new HttpSuccess(_salaryRank); @@ -7161,12 +7194,17 @@ export class ReportController extends Controller { "salaryProfileEmployee.posMasterNo", "salaryProfileEmployee.position", "salaryProfileEmployee.posType", + "salaryProfileEmployee.posTypeShort", "salaryProfileEmployee.posLevel", "salaryProfileEmployee.profileId", "salaryProfileEmployee.prefix", "salaryProfileEmployee.firstName", "salaryProfileEmployee.lastName", "salaryProfileEmployee.citizenId", + "salaryProfileEmployee.amount", + "salaryProfileEmployee.amountSpecial", + "salaryProfileEmployee.amountUse", + "salaryProfileEmployee.positionSalaryAmount", ]) .getMany(); @@ -7175,12 +7213,16 @@ 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, lastName: item.lastName, citizenId: item.citizenId, + amount: item.amount, + amountSpecial: item.amountSpecial, + amountUse: item.amountUse, + positionSalaryAmount: item.positionSalaryAmount, })); return new HttpSuccess(_salaryRank); @@ -7413,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; }[]; @@ -7433,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, @@ -7480,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; }[]; 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; 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);