API checkRole and history/user

This commit is contained in:
AdisakKanthawilang 2024-05-27 11:36:55 +07:00
parent 38871bcc80
commit 3167fe271e
7 changed files with 142 additions and 6 deletions

View file

@ -72,6 +72,27 @@ export class ProfileCertificateController extends Controller {
return new HttpSuccess(record);
}
/**
*
* @summary by keycloak
*
*/
@Get("history/user")
public async certificateHistoryUser(@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.certificateHistoryRepo.find({
where: {
histories: {
profileId: profile.id,
},
},
});
return new HttpSuccess(record);
}
@Get("history/{certificateId}")
@Example({
status: 200,