add api history/user

This commit is contained in:
AdisakKanthawilang 2024-05-27 15:17:27 +07:00
parent 3438b450ba
commit 7126d64d7e
6 changed files with 206 additions and 10 deletions

View file

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