From 65899d936a6a1f42e567fcdb15fd3b2b322e0aea Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 23 Apr 2025 09:27:31 +0700 Subject: [PATCH] =?UTF-8?q?api=20=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=A5?= =?UTF-8?q?=E0=B8=B0=E0=B9=80=E0=B8=AD=E0=B8=B5=E0=B8=A2=E0=B8=94=E0=B8=97?= =?UTF-8?q?=E0=B8=B8=E0=B8=99=20&=20=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84?= =?UTF-8?q?=E0=B8=82=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=A5=E0=B8=B0=E0=B9=80?= =?UTF-8?q?=E0=B8=AD=E0=B8=B5=E0=B8=A2=E0=B8=94=E0=B8=97=E0=B8=B8=E0=B8=99?= =?UTF-8?q?=20=E0=B8=AA=E0=B8=B3=E0=B8=AB=E0=B8=A3=E0=B8=B1=E0=B8=9A?= =?UTF-8?q?=E0=B9=80=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=AB=E0=B8=99=E0=B9=89?= =?UTF-8?q?=E0=B8=B2=E0=B8=97=E0=B8=B5=E0=B9=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DevelopmentScholarshipController.ts | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/controllers/DevelopmentScholarshipController.ts b/src/controllers/DevelopmentScholarshipController.ts index d3df7e8..8587ed5 100644 --- a/src/controllers/DevelopmentScholarshipController.ts +++ b/src/controllers/DevelopmentScholarshipController.ts @@ -559,6 +559,41 @@ export class DevelopmentScholarshipController extends Controller { return new HttpSuccess(getDevelopment); } + /** + * API รายละเอียดทุนของ admin + * + * @summary DEV_0 - รายละเอียดทุนของ admin # + * + * @param {string} id id รายการ + */ + @Get("admin/detail/{id}") + async GetDevelopemtScholarshipUserDetailAdminById(@Request() request: RequestWithUser, @Path() id: string) { + let _workflow = await new permission().Workflow(request, id, "SYS_DEV_SCHOLARSHIP"); + if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP"); + const getDevelopment = await this.developmentScholarshipRepository.findOne({ + where: { id: id }, + select: [ + "id", + "scholarshipYear", + "scholarshipType", + "fundType", + "bookNumber", + "bookDate", + "governmentDate", + "governmentEndDate", + "isGraduated", + "graduatedDate", + "graduatedReason", + "org", + ], + }); + if (!getDevelopment) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); + } + + return new HttpSuccess(getDevelopment); + } + /** * API รายละเอียดทุนของ user * @@ -622,6 +657,36 @@ export class DevelopmentScholarshipController extends Controller { return new HttpSuccess(getDevelopment.id); } + /** + * API แก้ไขรายการทุนของ admin + * + * @summary DEV_015 - แก้ไขรายการทุนของ admin #15 + * + * @param {string} id รายการ + */ + @Put("admin/detail/{id}") + async UpdateDevelopemtScholarshipAdminById( + @Path() id: string, + @Body() requestBody: UpdateDevelopmentScholarshipUser, + @Request() request: RequestWithUser, + ) { + await new permission().PermissionUpdate(request, "SYS_DEV_SCHOLARSHIP"); + const getDevelopment = await this.developmentScholarshipRepository.findOne({ + where: { id: id }, + }); + if (!getDevelopment) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); + } + const before = structuredClone(getDevelopment); + Object.assign(getDevelopment, requestBody); + getDevelopment.lastUpdateUserId = request.user.sub; + getDevelopment.lastUpdateFullName = request.user.name; + getDevelopment.lastUpdatedAt = new Date(); + await this.developmentScholarshipRepository.save(getDevelopment, { data: request }); + setLogDataDiff(request, { before, after: getDevelopment }); + return new HttpSuccess(getDevelopment.id); + } + /** * API เปลี่ยนสถานะ *