api รายละเอียดทุน & แก้ไขรายละเอียดทุน สำหรับเจ้าหน้าที่

This commit is contained in:
Bright 2025-04-23 09:27:31 +07:00
parent 588178f042
commit 65899d936a

View file

@ -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
*