add api history/user
This commit is contained in:
parent
3438b450ba
commit
7126d64d7e
6 changed files with 206 additions and 10 deletions
|
|
@ -75,6 +75,39 @@ export class ProfileDisciplineController extends Controller {
|
|||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary ประวัติแก้ไขข้อมูลวินัย by keycloak
|
||||
*
|
||||
*/
|
||||
@Get("history/user")
|
||||
public async disciplineHistoryUser(@Request() request: RequestWithUser) {
|
||||
const profile = await this.profileRepository.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const record = await this.disciplineHistoryRepository.find({
|
||||
where: {
|
||||
histories: {
|
||||
profileId: profile.id,
|
||||
},
|
||||
},
|
||||
select: [
|
||||
"id",
|
||||
"date",
|
||||
"level",
|
||||
"detail",
|
||||
"unStigma",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@Get("history/{disciplineId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue