ออกคำสั่งลูกจ้าง

This commit is contained in:
Kittapath 2024-06-13 10:17:57 +07:00
parent ae1a382dd0
commit b2178c6341
4 changed files with 203 additions and 22 deletions

72
package-lock.json generated
View file

@ -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",

View file

@ -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",

View file

@ -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<string, any> },
) {
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();
}
}

View file

@ -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;