fix and add profile by key cloak

This commit is contained in:
AdisakKanthawilang 2024-05-24 18:06:54 +07:00
parent 7b480b1247
commit eb85bdcb45
5 changed files with 143 additions and 19 deletions

View file

@ -79,6 +79,25 @@ export class ProfileAbilityController extends Controller {
return new HttpSuccess(getProfileAbilityId);
}
@Get("history/user")
public async getProfileAbilityHistoryUser(@Request() request: RequestWithUser) {
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const record = await this.profileAbilityHistoryRepo.find({
where: {
histories: {
profileId: profile.id,
},
},
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(record);
}
@Get("history/{abilityId}")
@Example({
status: 200,