add api history/user done

This commit is contained in:
AdisakKanthawilang 2024-05-28 10:20:50 +07:00
parent 10377150dd
commit a66f582c25
2 changed files with 42 additions and 0 deletions

View file

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

View file

@ -69,6 +69,27 @@ export class ProfileHonorEmployeeController extends Controller {
return new HttpSuccess(record);
}
/**
*
* @summary by keycloak
*
*/
@Get("history/user")
public async honorHistoryUser(@Request() request: RequestWithUser) {
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const record = await this.honorHistoryRepo.find({
where: {
histories: {
profileEmployeeId: profile.id,
},
},
});
return new HttpSuccess(record);
}
@Get("history/{honorId}")
@Example({
status: 200,