Merge branch 'develop' into adiDev
# Conflicts: # src/controllers/ProfileEmployeeController.ts
This commit is contained in:
commit
b7ce71d017
6 changed files with 199 additions and 2 deletions
|
|
@ -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")
|
||||
|
|
@ -2853,4 +2854,60 @@ export class ProfileEmployeeController extends Controller {
|
|||
});
|
||||
return new HttpSuccess(profiles);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ออกคำสั่งลูกจ้าง
|
||||
*
|
||||
* @summary ORG_038 - ออกคำสั่งลูกจ้าง (ADMIN) #
|
||||
*
|
||||
*/
|
||||
@Post("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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -222,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;
|
||||
|
|
@ -255,7 +257,7 @@ export type UpdateProfileChangePosition = {
|
|||
positionLevelOld: string;
|
||||
positionNumberOld: string;
|
||||
amountOld: number;
|
||||
dateCurrent : Date | null
|
||||
dateCurrent : Date;
|
||||
reason: string | null;
|
||||
};
|
||||
|
||||
|
|
|
|||
51
src/interfaces/call-api.ts
Normal file
51
src/interfaces/call-api.ts
Normal 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;
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateTableProfilechangeAddCurrent1718248767175 implements MigrationInterface {
|
||||
name = 'UpdateTableProfilechangeAddCurrent1718248767175'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`profileChangePosition\` ADD \`dateCurrent\` datetime NULL COMMENT 'ดำรงตำแหน่งในระดับปัจจุบันเมื่อ'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`profileChangePosition\` DROP COLUMN \`dateCurrent\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue