no message
This commit is contained in:
parent
573e0930f6
commit
a01669a230
4 changed files with 131 additions and 42 deletions
|
|
@ -3031,7 +3031,7 @@ export class ProfileController extends Controller {
|
||||||
*
|
*
|
||||||
* @param {string} id Id ทะเบียนประวัติ
|
* @param {string} id Id ทะเบียนประวัติ
|
||||||
*/
|
*/
|
||||||
@Put("salary/{id}")
|
@Post("leave/{id}")
|
||||||
async updateLeaveUser(
|
async updateLeaveUser(
|
||||||
@Path() id: string,
|
@Path() id: string,
|
||||||
@Body()
|
@Body()
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import {
|
||||||
CreateProfileEmployee,
|
CreateProfileEmployee,
|
||||||
UpdateProfileEmployee,
|
UpdateProfileEmployee,
|
||||||
ProfileEmployeeHistory,
|
ProfileEmployeeHistory,
|
||||||
UpdatePositionTempProfileEmployee
|
UpdatePositionTempProfileEmployee,
|
||||||
} from "../entities/ProfileEmployee";
|
} from "../entities/ProfileEmployee";
|
||||||
import { EmployeePosLevel } from "../entities/EmployeePosLevel";
|
import { EmployeePosLevel } from "../entities/EmployeePosLevel";
|
||||||
import { EmployeePosType } from "../entities/EmployeePosType";
|
import { EmployeePosType } from "../entities/EmployeePosType";
|
||||||
|
|
@ -520,7 +520,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
profile.dateRetire = calculateRetireDate(profile.birthDate);
|
profile.dateRetire = calculateRetireDate(profile.birthDate);
|
||||||
profile.dateRetireLaw = calculateRetireLaw(profile.birthDate);
|
profile.dateRetireLaw = calculateRetireLaw(profile.birthDate);
|
||||||
profile.citizenId = Extension.CheckCitizen(profile.citizenId);
|
profile.citizenId = Extension.CheckCitizen(profile.citizenId);
|
||||||
profile.employeeClass = profile.employeeClass.toLocaleUpperCase()
|
profile.employeeClass = profile.employeeClass.toLocaleUpperCase();
|
||||||
await this.profileRepo.save(profile);
|
await this.profileRepo.save(profile);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -803,25 +803,45 @@ export class ProfileEmployeeController extends Controller {
|
||||||
createdAt: _data.createdAt,
|
createdAt: _data.createdAt,
|
||||||
dateRetireLaw: _data.dateRetireLaw,
|
dateRetireLaw: _data.dateRetireLaw,
|
||||||
draftOrganizationOrganization:
|
draftOrganizationOrganization:
|
||||||
_data.nodeTemp == "0" ? _data.rootTemp :
|
_data.nodeTemp == "0"
|
||||||
_data.nodeTemp == "1" ? _data.child1Temp :
|
? _data.rootTemp
|
||||||
_data.nodeTemp == "2" ? _data.child2Temp :
|
: _data.nodeTemp == "1"
|
||||||
_data.nodeTemp == "3" ? _data.child3Temp :
|
? _data.child1Temp
|
||||||
_data.nodeTemp == "4" ? _data.child4Temp : null,
|
: _data.nodeTemp == "2"
|
||||||
|
? _data.child2Temp
|
||||||
|
: _data.nodeTemp == "3"
|
||||||
|
? _data.child3Temp
|
||||||
|
: _data.nodeTemp == "4"
|
||||||
|
? _data.child4Temp
|
||||||
|
: null,
|
||||||
draftPositionEmployee: _data.positionTemp,
|
draftPositionEmployee: _data.positionTemp,
|
||||||
draftOrgEmployeeStatus: _data.statusTemp,
|
draftOrgEmployeeStatus: _data.statusTemp,
|
||||||
node: _data.nodeTemp,
|
node: _data.nodeTemp,
|
||||||
nodeId: _data.nodeIdTemp,
|
nodeId: _data.nodeIdTemp,
|
||||||
nodeName: _data.nodeTemp == "0" ? _data.rootTemp :
|
nodeName:
|
||||||
_data.nodeTemp == "1" ? _data.child1Temp :
|
_data.nodeTemp == "0"
|
||||||
_data.nodeTemp == "2" ? _data.child2Temp :
|
? _data.rootTemp
|
||||||
_data.nodeTemp == "3" ? _data.child3Temp :
|
: _data.nodeTemp == "1"
|
||||||
_data.nodeTemp == "4" ? _data.child4Temp : null,
|
? _data.child1Temp
|
||||||
nodeShortName: _data.nodeTemp == "0" ? _data.rootShortNameTemp :
|
: _data.nodeTemp == "2"
|
||||||
_data.nodeTemp == "1" ? _data.child1ShortNameTemp :
|
? _data.child2Temp
|
||||||
_data.nodeTemp == "2" ? _data.child1ShortNameTemp :
|
: _data.nodeTemp == "3"
|
||||||
_data.nodeTemp == "3" ? _data.child3ShortNameTemp :
|
? _data.child3Temp
|
||||||
_data.nodeTemp == "4" ? _data.child4ShortNameTemp: null,
|
: _data.nodeTemp == "4"
|
||||||
|
? _data.child4Temp
|
||||||
|
: null,
|
||||||
|
nodeShortName:
|
||||||
|
_data.nodeTemp == "0"
|
||||||
|
? _data.rootShortNameTemp
|
||||||
|
: _data.nodeTemp == "1"
|
||||||
|
? _data.child1ShortNameTemp
|
||||||
|
: _data.nodeTemp == "2"
|
||||||
|
? _data.child1ShortNameTemp
|
||||||
|
: _data.nodeTemp == "3"
|
||||||
|
? _data.child3ShortNameTemp
|
||||||
|
: _data.nodeTemp == "4"
|
||||||
|
? _data.child4ShortNameTemp
|
||||||
|
: null,
|
||||||
root: _data.rootTemp ? _data.rootTemp : null,
|
root: _data.rootTemp ? _data.rootTemp : null,
|
||||||
rootId: _data.rootIdTemp ? _data.rootIdTemp : null,
|
rootId: _data.rootIdTemp ? _data.rootIdTemp : null,
|
||||||
rootShortName: _data.rootShortNameTemp ? _data.rootShortNameTemp : null,
|
rootShortName: _data.rootShortNameTemp ? _data.rootShortNameTemp : null,
|
||||||
|
|
@ -837,7 +857,6 @@ export class ProfileEmployeeController extends Controller {
|
||||||
child4: _data.child4Temp ? _data.child4Temp : null,
|
child4: _data.child4Temp ? _data.child4Temp : null,
|
||||||
child4Id: _data.child4IdTemp ? _data.child4IdTemp : null,
|
child4Id: _data.child4IdTemp ? _data.child4IdTemp : null,
|
||||||
child4ShortName: _data.child4ShortNameTemp ? _data.child4ShortNameTemp : null,
|
child4ShortName: _data.child4ShortNameTemp ? _data.child4ShortNameTemp : null,
|
||||||
|
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
@ -1591,7 +1610,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
case 1: {
|
case 1: {
|
||||||
const data = await this.child1Repository.findOne({
|
const data = await this.child1Repository.findOne({
|
||||||
where: { id: body.nodeId },
|
where: { id: body.nodeId },
|
||||||
relations: ["orgRoot"]
|
relations: ["orgRoot"],
|
||||||
});
|
});
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
profileEmp.rootIdTemp = data.orgRoot.id;
|
profileEmp.rootIdTemp = data.orgRoot.id;
|
||||||
|
|
@ -1605,7 +1624,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
case 2: {
|
case 2: {
|
||||||
const data = await this.child2Repository.findOne({
|
const data = await this.child2Repository.findOne({
|
||||||
where: { id: body.nodeId },
|
where: { id: body.nodeId },
|
||||||
relations: ["orgRoot", "orgChild1"]
|
relations: ["orgRoot", "orgChild1"],
|
||||||
});
|
});
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
profileEmp.rootIdTemp = data.orgRoot.id;
|
profileEmp.rootIdTemp = data.orgRoot.id;
|
||||||
|
|
@ -1622,7 +1641,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
case 3: {
|
case 3: {
|
||||||
const data = await this.child3Repository.findOne({
|
const data = await this.child3Repository.findOne({
|
||||||
where: { id: body.nodeId },
|
where: { id: body.nodeId },
|
||||||
relations: ["orgRoot", "orgChild1", "orgChild2"]
|
relations: ["orgRoot", "orgChild1", "orgChild2"],
|
||||||
});
|
});
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
profileEmp.rootIdTemp = data.orgRoot.id;
|
profileEmp.rootIdTemp = data.orgRoot.id;
|
||||||
|
|
@ -1642,7 +1661,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
case 4: {
|
case 4: {
|
||||||
const data = await this.child4Repository.findOne({
|
const data = await this.child4Repository.findOne({
|
||||||
where: { id: body.nodeId },
|
where: { id: body.nodeId },
|
||||||
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3"]
|
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3"],
|
||||||
});
|
});
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
profileEmp.rootIdTemp = data.orgRoot.id;
|
profileEmp.rootIdTemp = data.orgRoot.id;
|
||||||
|
|
@ -2328,4 +2347,29 @@ export class ProfileEmployeeController extends Controller {
|
||||||
});
|
});
|
||||||
return new HttpSuccess(formattedData);
|
return new HttpSuccess(formattedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API อัพเดทเกษียณ
|
||||||
|
*
|
||||||
|
* @summary อัพเดทเกษียณ (ADMIN)
|
||||||
|
*
|
||||||
|
* @param {string} id Id ทะเบียนประวัติ
|
||||||
|
*/
|
||||||
|
@Post("leave/{id}")
|
||||||
|
async updateLeaveUser(
|
||||||
|
@Path() id: string,
|
||||||
|
@Body()
|
||||||
|
requestBody: { isLeave: boolean; leaveReason: string; dateLeave: Date },
|
||||||
|
) {
|
||||||
|
const profile = await this.profileRepo.findOne({
|
||||||
|
where: { id: id },
|
||||||
|
});
|
||||||
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
||||||
|
profile.isLeave = requestBody.isLeave;
|
||||||
|
profile.leaveReason = requestBody.leaveReason;
|
||||||
|
profile.dateLeave = requestBody.dateLeave;
|
||||||
|
await this.profileRepo.save(profile);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -181,6 +181,27 @@ export class ProfileEmployee extends EntityBase {
|
||||||
})
|
})
|
||||||
isProbation: boolean;
|
isProbation: boolean;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
comment: "เกษียณ",
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
isLeave: boolean;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "เหตุผลเกษียณ",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
leaveReason: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "datetime",
|
||||||
|
comment: "วันพ้นราชการ",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
dateLeave: Date;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
type: "datetime",
|
type: "datetime",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateTableSalaryProfileempAddTemp1717688401552 implements MigrationInterface {
|
||||||
|
name = 'UpdateTableSalaryProfileempAddTemp1717688401552'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`isLeave\` tinyint NOT NULL COMMENT 'เกษียณ' DEFAULT 0`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`leaveReason\` varchar(255) NULL COMMENT 'เหตุผลเกษียณ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`dateLeave\` datetime NULL COMMENT 'วันพ้นราชการ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`isLeave\` tinyint NOT NULL COMMENT 'เกษียณ' DEFAULT 0`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`leaveReason\` varchar(255) NULL COMMENT 'เหตุผลเกษียณ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`dateLeave\` datetime NULL COMMENT 'วันพ้นราชการ'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`dateLeave\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`leaveReason\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`isLeave\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`dateLeave\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`leaveReason\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`isLeave\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue