From aa92f377cf05e124dc93f95fc1584dc152437dc3 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 13 Jun 2024 10:10:48 +0700 Subject: [PATCH 1/3] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=E0=B8=9F=E0=B8=B4=E0=B8=A5=E0=B8=94=E0=B9=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entities/ProfileChangePosition.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/entities/ProfileChangePosition.ts b/src/entities/ProfileChangePosition.ts index 575f1cd6..7adff5b8 100644 --- a/src/entities/ProfileChangePosition.ts +++ b/src/entities/ProfileChangePosition.ts @@ -31,6 +31,8 @@ export class ProfileChangePosition extends EntityBase { @Column({ nullable: true, comment: "ข้อมูลหน่วยงานเดิม เงินเดือน", type: "double", default: null }) amountOld: number; + @Column({ nullable: true, type: "datetime", comment: "ดำรงตำแหน่งในระดับปัจจุบันเมื่อ", default: null }) + dateCurrent: Date @Column({ nullable: true, comment: "profile Id", default: null }) profileId: string; @@ -255,7 +257,7 @@ export type UpdateProfileChangePosition = { positionLevelOld: string; positionNumberOld: string; amountOld: number; - dateCurrent : Date | null + dateCurrent : Date; reason: string | null; }; From b2178c63417c53478704e6629579de57c3495ea1 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 13 Jun 2024 10:17:57 +0700 Subject: [PATCH 2/3] =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=84?= =?UTF-8?q?=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87=E0=B8=A5=E0=B8=B9?= =?UTF-8?q?=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 72 +++++++++++++ package.json | 1 + src/controllers/ProfileEmployeeController.ts | 101 +++++++++++++++---- src/interfaces/call-api.ts | 51 ++++++++++ 4 files changed, 203 insertions(+), 22 deletions(-) create mode 100644 src/interfaces/call-api.ts diff --git a/package-lock.json b/package-lock.json index cbd97229..c2d3cc29 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "@nestjs/platform-express": "^10.3.9", "@tsoa/runtime": "^6.0.0", + "axios": "^1.7.2", "cors": "^2.8.5", "dotenv": "^16.3.1", "express": "^4.18.2", @@ -648,6 +649,11 @@ "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", "integrity": "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==" }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, "node_modules/available-typed-arrays": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", @@ -659,6 +665,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/axios": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", + "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -1106,6 +1122,17 @@ "resolved": "https://registry.npmjs.org/colors-console/-/colors-console-1.0.3.tgz", "integrity": "sha512-Q31K32UwadWqAxs+Iu46gNm4HJqUwrTJT2zen5NnhkKE5w7uqeZQZiuODUOxM/zOtHfiUTkia0io6zbN/VcCUQ==" }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/commander": { "version": "2.20.3", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", @@ -1271,6 +1298,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/denque": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", @@ -1662,6 +1697,25 @@ "node": ">= 0.8" } }, + "node_modules/follow-redirects": { + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/for-each": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", @@ -1685,6 +1739,19 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -3319,6 +3386,11 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/pstree.remy": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", diff --git a/package.json b/package.json index b70950d1..6a7eb347 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "dependencies": { "@nestjs/platform-express": "^10.3.9", "@tsoa/runtime": "^6.0.0", + "axios": "^1.7.2", "cors": "^2.8.5", "dotenv": "^16.3.1", "express": "^4.18.2", diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 6be20277..fe09f34b 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -58,6 +58,7 @@ import { UpdateEmploymentProfileEmployee, } from "../entities/ProfileEmployeeEmployment"; import { ProfileEmployeeEmploymentHistory } from "../entities/ProfileEmployeeEmploymentHistory"; +import CallAPI from "../interfaces/call-api"; @Route("api/v1/org/profile-employee") @Tags("ProfileEmployee") @@ -1549,28 +1550,28 @@ export class ProfileEmployeeController extends Controller { posLevelId: item.posLevelId, posLevelName: item.posLevel?.posLevelName, profileEducation: latestProfileEducation?.degree ?? null, - // ? { - // id: latestProfileEducation.id, - // degree: latestProfileEducation.degree, - // country: latestProfileEducation.country, - // duration: latestProfileEducation.duration, - // durationYear: latestProfileEducation.durationYear, - // field: latestProfileEducation.field, - // finishDate: latestProfileEducation.finishDate, - // fundName: latestProfileEducation.fundName, - // gpa: latestProfileEducation.gpa, - // institute: latestProfileEducation.institute, - // other: latestProfileEducation.other, - // startDate: latestProfileEducation.startDate, - // endDate: latestProfileEducation.endDate, - // educationLevel: latestProfileEducation.educationLevel, - // positionPath: latestProfileEducation.positionPath, - // positionPathId: latestProfileEducation.positionPathId, - // isDate: latestProfileEducation.isDate, - // isEducation: latestProfileEducation.isEducation, - // note: latestProfileEducation.note, - // } - // : null, + // ? { + // id: latestProfileEducation.id, + // degree: latestProfileEducation.degree, + // country: latestProfileEducation.country, + // duration: latestProfileEducation.duration, + // durationYear: latestProfileEducation.durationYear, + // field: latestProfileEducation.field, + // finishDate: latestProfileEducation.finishDate, + // fundName: latestProfileEducation.fundName, + // gpa: latestProfileEducation.gpa, + // institute: latestProfileEducation.institute, + // other: latestProfileEducation.other, + // startDate: latestProfileEducation.startDate, + // endDate: latestProfileEducation.endDate, + // educationLevel: latestProfileEducation.educationLevel, + // positionPath: latestProfileEducation.positionPath, + // positionPathId: latestProfileEducation.positionPathId, + // isDate: latestProfileEducation.isDate, + // isEducation: latestProfileEducation.isEducation, + // note: latestProfileEducation.note, + // } + // : null, }; }), ); @@ -2849,4 +2850,60 @@ export class ProfileEmployeeController extends Controller { }); return new HttpSuccess(profiles); } + + /** + * API ออกคำสั่งลูกจ้าง + * + * @summary ORG_038 - ออกคำสั่งลูกจ้าง (ADMIN) # + * + */ + @Get("report/resume") + async doneReport( + @Body() + body: { + result: { + id: string; + personId: string; + templateDoc: string; + amount: string; + positionSalaryAmount: string; + mouthSalaryAmount: string; + refCommandNo: string; + }[]; + }, + @Request() request: { user: Record }, + ) { + await Promise.all( + body.result.map(async (v) => { + const profile = await this.profileRepo.findOne({ + where: { + id: v.id, + }, + relations: ["posType", "posLevel"], + }); + if (profile != null) { + await new CallAPI() + .PostData(request, "org/profile/salary", { + profileId: profile.id, + date: new Date(), + amount: v.amount, + positionSalaryAmount: v.positionSalaryAmount, + mouthSalaryAmount: v.mouthSalaryAmount, + posNo: profile.posMasterNoTemp, + position: profile.positionTemp, + positionType: profile.posTypeNameTemp, + positionLevel: profile.posLevelNameTemp, + refCommandNo: v.refCommandNo, + templateDoc: v.templateDoc, + }) + .then(async (x) => { + profile.statusTemp = "DONE"; + profile.employeeClass = "TEMP"; + await this.profileRepo.save(profile); + }); + } + }), + ); + return new HttpSuccess(); + } } diff --git a/src/interfaces/call-api.ts b/src/interfaces/call-api.ts new file mode 100644 index 00000000..4cbd1a5a --- /dev/null +++ b/src/interfaces/call-api.ts @@ -0,0 +1,51 @@ +import { + Controller, + Request, + Get, + Post, + Put, + Delete, + Patch, + Route, + Security, + Tags, + Path, +} from "tsoa"; +import axios from "axios"; + +class CallAPI { + //Get + public async GetData(request: any, @Path() path: any) { + const token = request.headers.authorization; + const url = process.env.API + path; + try { + const response = await axios.get(url, { + headers: { + Authorization: `${token}`, + "Content-Type": "application/json", + }, + }); + return response.data.result; + } catch (error) { + throw error; + } + } + //Post + public async PostData(request: any, @Path() path: any, sendData: any) { + const token = request.headers.authorization; + const url = process.env.API + path; + try { + const response = await axios.post(url, sendData, { + headers: { + Authorization: `${token}`, + "Content-Type": "application/json", + }, + }); + return response.data.result; + } catch (error) { + throw error; + } + } +} + +export default CallAPI; From 7b2600988bf348da66294d9b1658d019948d06db Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 13 Jun 2024 11:54:57 +0700 Subject: [PATCH 3/3] no message --- src/controllers/ProfileEmployeeController.ts | 2 +- src/entities/ProfileChangePosition.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index fe09f34b..4eadd02a 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -2857,7 +2857,7 @@ export class ProfileEmployeeController extends Controller { * @summary ORG_038 - ออกคำสั่งลูกจ้าง (ADMIN) # * */ - @Get("report/resume") + @Post("report/resume") async doneReport( @Body() body: { diff --git a/src/entities/ProfileChangePosition.ts b/src/entities/ProfileChangePosition.ts index 7adff5b8..f7f40f06 100644 --- a/src/entities/ProfileChangePosition.ts +++ b/src/entities/ProfileChangePosition.ts @@ -224,7 +224,7 @@ export class ProfileItem { positionLevelOld: string | null; positionNumberOld: string | null; organizationOld: string | null; - organizationPositionOld: string | null; + organizationPositionOld?: string | null; amountOld: number | null; educationOld: string | null; rootOld: string | null;