update field and api update duty
This commit is contained in:
parent
5abaacdf15
commit
879b6bfd0b
3 changed files with 49 additions and 0 deletions
|
|
@ -193,6 +193,34 @@ export class DirectorController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API สำหรับแก้ไขรายละเอียดกรรมการ
|
||||
*
|
||||
* @summary แก้ไขรายละเอียดกรรมการ (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Put("duty/{id}")
|
||||
async updateDuty(@Path() id: string, @Body() body:{duty: string} , @Request() request: RequestWithUser) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_EVA_INFO");
|
||||
let director = await this.directorRepository.findOneBy({ id });
|
||||
if (!director) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกรรมการ");
|
||||
}
|
||||
const before = structuredClone(director);
|
||||
director.duty = body?.duty;
|
||||
director.lastUpdateUserId = request.user.sub;
|
||||
director.lastUpdateFullName = request.user.name;
|
||||
director.lastUpdatedAt = new Date();
|
||||
await this.directorRepository.save(director, { data: request });
|
||||
setLogDataDiff(request, { before, after: director });
|
||||
return new HttpSuccess();
|
||||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* API สำหรับแก้ไขรายละเอียดกรรมการ
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue