api รักษาการแทน

This commit is contained in:
Kittapath 2024-06-19 23:03:54 +07:00
parent f7c553ec1d
commit 9de005c7ae
8 changed files with 752 additions and 69 deletions

View file

@ -748,6 +748,42 @@ export class ProfileController extends Controller {
return new HttpSuccess(profile.id);
}
/**
* API
*
* @summary ORG_065 - (ADMIN) #XXX
*
*/
@Post("allv2")
async createProfileAllV2(
@Request() request: RequestWithUser,
@Body() body: CreateProfileAllFields,
) {
const profileExist = await this.profileRepo.findOneBy({ citizenId: body.citizenId });
if (profileExist) {
return new HttpSuccess(profileExist.id);
}
if (body.posLevelId === "") body.posLevelId = null;
if (body.posTypeId === "") body.posTypeId = null;
if (body.posLevelId && !(await this.posLevelRepo.findOneBy({ id: body.posLevelId }))) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่งนี้");
}
if (body.posTypeId && !(await this.posTypeRepo.findOneBy({ id: body.posTypeId }))) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
}
const profile: Profile = Object.assign(new Profile(), body);
profile.createdUserId = request.user.sub;
profile.createdFullName = request.user.name;
profile.lastUpdateUserId = request.user.sub;
profile.lastUpdateFullName = request.user.name;
await this.profileRepo.save(profile);
return new HttpSuccess(profile.id);
}
/**
* API
*
@ -784,10 +820,11 @@ export class ProfileController extends Controller {
date: body.date,
refCommandNo: body.refCommandNo,
templateDoc: body.salaryRef,
position: //profile.position,
//profile.position,
position:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
positionType:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].positionType
@ -879,10 +916,10 @@ export class ProfileController extends Controller {
date: body.date,
refCommandNo: body.refCommandNo,
templateDoc: body.salaryRef,
position:
position:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
positionType:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].positionType
@ -961,8 +998,7 @@ export class ProfileController extends Controller {
}
let dateLeave_: any = body.date;
profile.isLeave = true;
profile.leaveReason =
"ได้รับโทษทางวินัย ปลดออกจากราชการ";
profile.leaveReason = "ได้รับโทษทางวินัย ปลดออกจากราชการ";
profile.dateLeave = dateLeave_;
profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name;
@ -971,10 +1007,10 @@ export class ProfileController extends Controller {
date: body.date,
refCommandNo: body.refCommandNo,
templateDoc: body.salaryRef,
position:
position:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
positionType:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].positionType
@ -1053,8 +1089,7 @@ export class ProfileController extends Controller {
}
let dateLeave_: any = body.date;
profile.isLeave = true;
profile.leaveReason =
"ได้รับโทษทางวินัย ไล่ออกจากราชการ";
profile.leaveReason = "ได้รับโทษทางวินัย ไล่ออกจากราชการ";
profile.dateLeave = dateLeave_;
profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name;
@ -1063,10 +1098,10 @@ export class ProfileController extends Controller {
date: body.date,
refCommandNo: body.refCommandNo,
templateDoc: body.salaryRef,
position:
position:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
positionType:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].positionType
@ -1145,8 +1180,7 @@ export class ProfileController extends Controller {
}
let dateLeave_: any = body.date;
profile.isLeave = true;
profile.leaveReason =
"ได้รับโทษทางวินัย พักจากราชการ";
profile.leaveReason = "ได้รับโทษทางวินัย พักจากราชการ";
profile.dateLeave = dateLeave_;
profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name;
@ -1155,10 +1189,10 @@ export class ProfileController extends Controller {
date: body.date,
refCommandNo: body.refCommandNo,
templateDoc: body.salaryRef,
position:
position:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
positionType:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].positionType
@ -1237,8 +1271,7 @@ export class ProfileController extends Controller {
}
let dateLeave_: any = body.date;
profile.isLeave = true;
profile.leaveReason =
"ได้รับโทษทางวินัย ให้ออกจากราชการไว้ก่อน";
profile.leaveReason = "ได้รับโทษทางวินัย ให้ออกจากราชการไว้ก่อน";
profile.dateLeave = dateLeave_;
profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name;
@ -1247,10 +1280,10 @@ export class ProfileController extends Controller {
date: body.date,
refCommandNo: body.refCommandNo,
templateDoc: body.salaryRef,
position:
position:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
positionType:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].positionType
@ -1329,8 +1362,7 @@ export class ProfileController extends Controller {
}
let dateLeave_: any = body.date;
profile.isLeave = true;
profile.leaveReason =
"ได้รับโทษทางวินัย ลงโทษ ภาคทัณฑ์";
profile.leaveReason = "ได้รับโทษทางวินัย ลงโทษ ภาคทัณฑ์";
profile.dateLeave = dateLeave_;
profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name;
@ -1339,10 +1371,10 @@ export class ProfileController extends Controller {
date: body.date,
refCommandNo: body.refCommandNo,
templateDoc: body.salaryRef,
position:
position:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
positionType:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].positionType
@ -1421,8 +1453,7 @@ export class ProfileController extends Controller {
}
let dateLeave_: any = body.date;
profile.isLeave = true;
profile.leaveReason =
"ได้รับโทษทางวินัย ลงโทษ ตัดเงินเดือน";
profile.leaveReason = "ได้รับโทษทางวินัย ลงโทษ ตัดเงินเดือน";
profile.dateLeave = dateLeave_;
profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name;
@ -1431,10 +1462,10 @@ export class ProfileController extends Controller {
date: body.date,
refCommandNo: body.refCommandNo,
templateDoc: body.salaryRef,
position:
position:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
positionType:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].positionType
@ -1513,8 +1544,7 @@ export class ProfileController extends Controller {
}
let dateLeave_: any = body.date;
profile.isLeave = true;
profile.leaveReason =
"ได้รับโทษทางวินัย ลงโทษ ลดขั้นเงินเดือน";
profile.leaveReason = "ได้รับโทษทางวินัย ลงโทษ ลดขั้นเงินเดือน";
profile.dateLeave = dateLeave_;
profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name;
@ -1523,10 +1553,10 @@ export class ProfileController extends Controller {
date: body.date,
refCommandNo: body.refCommandNo,
templateDoc: body.salaryRef,
position:
position:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
positionType:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].positionType
@ -1605,8 +1635,7 @@ export class ProfileController extends Controller {
}
let dateLeave_: any = body.date;
profile.isLeave = true;
profile.leaveReason =
"ได้รับโทษทางวินัย เพิ่มโทษ";
profile.leaveReason = "ได้รับโทษทางวินัย เพิ่มโทษ";
profile.dateLeave = dateLeave_;
profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name;
@ -1615,10 +1644,10 @@ export class ProfileController extends Controller {
date: body.date,
refCommandNo: body.refCommandNo,
templateDoc: body.salaryRef,
position:
position:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
positionType:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].positionType
@ -1697,8 +1726,7 @@ export class ProfileController extends Controller {
}
let dateLeave_: any = body.date;
profile.isLeave = true;
profile.leaveReason =
"ได้รับโทษทางวินัย ยุติเรื่อง";
profile.leaveReason = "ได้รับโทษทางวินัย ยุติเรื่อง";
profile.dateLeave = dateLeave_;
profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name;
@ -1707,10 +1735,10 @@ export class ProfileController extends Controller {
date: body.date,
refCommandNo: body.refCommandNo,
templateDoc: body.salaryRef,
position:
position:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
positionType:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].positionType
@ -1789,8 +1817,7 @@ export class ProfileController extends Controller {
}
let dateLeave_: any = body.date;
profile.isLeave = true;
profile.leaveReason =
"ได้รับโทษทางวินัย งดโทษ";
profile.leaveReason = "ได้รับโทษทางวินัย งดโทษ";
profile.dateLeave = dateLeave_;
profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name;
@ -1799,10 +1826,10 @@ export class ProfileController extends Controller {
date: body.date,
refCommandNo: body.refCommandNo,
templateDoc: body.salaryRef,
position:
position:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
positionType:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].positionType
@ -4258,7 +4285,7 @@ export class ProfileController extends Controller {
date: requestBody.dateLeave,
amount: profileSalary?.amount ?? null,
positionSalaryAmount: profileSalary?.positionSalaryAmount ?? null,
mouthSalaryAmount: profileSalary?.mouthSalaryAmount?? null,
mouthSalaryAmount: profileSalary?.mouthSalaryAmount ?? null,
posNo: profileSalary?.posNo ?? null,
position: profileSalary?.position ?? null,
positionLine: profileSalary?.positionLine ?? null,