แก้ import data ไมพบข้อมูลในทะเบียนประวัติ
This commit is contained in:
parent
8c39019f4a
commit
78ce7fa612
2 changed files with 92 additions and 6 deletions
|
|
@ -359,6 +359,52 @@ export class DevelopmentScholarshipController extends Controller {
|
|||
return new HttpSuccess(formattedData);
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขทุนการศึกษา/ฝึกอบรม
|
||||
*
|
||||
* @summary DEV_012 - แก้ไขทุนการศึกษา/ฝึกอบรม #12
|
||||
*
|
||||
* @param {string} id Id ข้าราชการฯที่ได้รับทุนการศึกษา
|
||||
*/
|
||||
@Put("admin/{id}")
|
||||
async UpdateDevelopmentScholarshipAdminById(
|
||||
@Path() id: string,
|
||||
@Body() requestBody: UpdateDevelopmentScholarship,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_DEV_SCHOLARSHIP");
|
||||
const development = await this.developmentScholarshipRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!development) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
|
||||
}
|
||||
if (requestBody.posTypeId != null) {
|
||||
const checkId = await this.posTypeRepository.findOne({
|
||||
where: { id: requestBody.posTypeId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
|
||||
}
|
||||
}
|
||||
if (requestBody.posLevelId != null) {
|
||||
const checkId = await this.posLevelRepository.findOne({
|
||||
where: { id: requestBody.posLevelId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
|
||||
}
|
||||
}
|
||||
const before = structuredClone(development);
|
||||
Object.assign(development, requestBody);
|
||||
development.lastUpdateUserId = request.user.sub;
|
||||
development.lastUpdateFullName = request.user.name;
|
||||
development.lastUpdatedAt = new Date();
|
||||
await this.developmentScholarshipRepository.save(development, { data: request });
|
||||
setLogDataDiff(request, { before, after: development });
|
||||
return new HttpSuccess(development.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายละเอียดทุนการศึกษา/ฝึกอบรม ADMIN
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue