update field and api update duty

This commit is contained in:
AdisakKanthawilang 2025-04-18 13:18:11 +07:00
parent 5abaacdf15
commit 879b6bfd0b
3 changed files with 49 additions and 0 deletions

View file

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