no message

This commit is contained in:
Kittapath 2024-06-07 03:05:57 +07:00
parent 573e0930f6
commit a01669a230
4 changed files with 131 additions and 42 deletions

View file

@ -3031,7 +3031,7 @@ export class ProfileController extends Controller {
*
* @param {string} id Id
*/
@Put("salary/{id}")
@Post("leave/{id}")
async updateLeaveUser(
@Path() id: string,
@Body()

View file

@ -27,7 +27,7 @@ import {
CreateProfileEmployee,
UpdateProfileEmployee,
ProfileEmployeeHistory,
UpdatePositionTempProfileEmployee
UpdatePositionTempProfileEmployee,
} from "../entities/ProfileEmployee";
import { EmployeePosLevel } from "../entities/EmployeePosLevel";
import { EmployeePosType } from "../entities/EmployeePosType";
@ -505,7 +505,7 @@ export class ProfileEmployeeController extends Controller {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
}
if(body.employeeClass == null || body.employeeClass == undefined || body.employeeClass == ""){
if (body.employeeClass == null || body.employeeClass == undefined || body.employeeClass == "") {
body.employeeClass = "PERM";
}
if (!["PERM", "TEMP"].includes(body.employeeClass.toLocaleUpperCase())) {
@ -520,7 +520,7 @@ export class ProfileEmployeeController extends Controller {
profile.dateRetire = calculateRetireDate(profile.birthDate);
profile.dateRetireLaw = calculateRetireLaw(profile.birthDate);
profile.citizenId = Extension.CheckCitizen(profile.citizenId);
profile.employeeClass = profile.employeeClass.toLocaleUpperCase()
profile.employeeClass = profile.employeeClass.toLocaleUpperCase();
await this.profileRepo.save(profile);
return new HttpSuccess();
}
@ -570,7 +570,7 @@ export class ProfileEmployeeController extends Controller {
}),
);
if(body.employeeClass == null || body.employeeClass == undefined || body.employeeClass == ""){
if (body.employeeClass == null || body.employeeClass == undefined || body.employeeClass == "") {
body.employeeClass = "PERM";
}
if (!["PERM", "TEMP"].includes(body.employeeClass.toLocaleUpperCase())) {
@ -796,35 +796,55 @@ export class ProfileEmployeeController extends Controller {
position: _data.position,
posNo: shortName,
employeeClass: _data.employeeClass == null ? null : _data.employeeClass,
govAge: Extension.CalculateGovAge(_data.dateAppoint,0,0),
age: Extension.CalculateAgeStrV2(_data.birthDate,0,0),
dateAppoint: _data.dateAppoint,
govAge: Extension.CalculateGovAge(_data.dateAppoint, 0, 0),
age: Extension.CalculateAgeStrV2(_data.birthDate, 0, 0),
dateAppoint: _data.dateAppoint,
dateStart: _data.dateStart,
createdAt: _data.createdAt,
createdAt: _data.createdAt,
dateRetireLaw: _data.dateRetireLaw,
draftOrganizationOrganization:
_data.nodeTemp == "0" ? _data.rootTemp :
_data.nodeTemp == "1" ? _data.child1Temp :
_data.nodeTemp == "2" ? _data.child2Temp :
_data.nodeTemp == "3" ? _data.child3Temp :
_data.nodeTemp == "4" ? _data.child4Temp : null,
draftOrganizationOrganization:
_data.nodeTemp == "0"
? _data.rootTemp
: _data.nodeTemp == "1"
? _data.child1Temp
: _data.nodeTemp == "2"
? _data.child2Temp
: _data.nodeTemp == "3"
? _data.child3Temp
: _data.nodeTemp == "4"
? _data.child4Temp
: null,
draftPositionEmployee: _data.positionTemp,
draftOrgEmployeeStatus: _data.statusTemp,
node: _data.nodeTemp,
nodeId: _data.nodeIdTemp,
nodeName: _data.nodeTemp == "0" ? _data.rootTemp :
_data.nodeTemp == "1" ? _data.child1Temp :
_data.nodeTemp == "2" ? _data.child2Temp :
_data.nodeTemp == "3" ? _data.child3Temp :
_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,
nodeName:
_data.nodeTemp == "0"
? _data.rootTemp
: _data.nodeTemp == "1"
? _data.child1Temp
: _data.nodeTemp == "2"
? _data.child2Temp
: _data.nodeTemp == "3"
? _data.child3Temp
: _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,
rootId: _data.rootIdTemp ? _data.rootIdTemp : null,
rootShortName: _data.rootShortNameTemp ?_data.rootShortNameTemp : null,
rootShortName: _data.rootShortNameTemp ? _data.rootShortNameTemp : null,
child1: _data.child1Temp ? _data.child1Temp : null,
child1Id: _data.child1IdTemp ? _data.child1IdTemp : null,
child1ShortName: _data.child1ShortNameTemp ? _data.child1ShortNameTemp : null,
@ -837,7 +857,6 @@ export class ProfileEmployeeController extends Controller {
child4: _data.child4Temp ? _data.child4Temp : null,
child4Id: _data.child4IdTemp ? _data.child4IdTemp : null,
child4ShortName: _data.child4ShortNameTemp ? _data.child4ShortNameTemp : null,
};
}),
);
@ -1591,7 +1610,7 @@ export class ProfileEmployeeController extends Controller {
case 1: {
const data = await this.child1Repository.findOne({
where: { id: body.nodeId },
relations: ["orgRoot"]
relations: ["orgRoot"],
});
if (data != null) {
profileEmp.rootIdTemp = data.orgRoot.id;
@ -1605,7 +1624,7 @@ export class ProfileEmployeeController extends Controller {
case 2: {
const data = await this.child2Repository.findOne({
where: { id: body.nodeId },
relations: ["orgRoot", "orgChild1"]
relations: ["orgRoot", "orgChild1"],
});
if (data != null) {
profileEmp.rootIdTemp = data.orgRoot.id;
@ -1622,7 +1641,7 @@ export class ProfileEmployeeController extends Controller {
case 3: {
const data = await this.child3Repository.findOne({
where: { id: body.nodeId },
relations: ["orgRoot", "orgChild1", "orgChild2"]
relations: ["orgRoot", "orgChild1", "orgChild2"],
});
if (data != null) {
profileEmp.rootIdTemp = data.orgRoot.id;
@ -1642,7 +1661,7 @@ export class ProfileEmployeeController extends Controller {
case 4: {
const data = await this.child4Repository.findOne({
where: { id: body.nodeId },
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3"]
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3"],
});
if (data != null) {
profileEmp.rootIdTemp = data.orgRoot.id;
@ -2328,4 +2347,29 @@ export class ProfileEmployeeController extends Controller {
});
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();
}
}