get ข้อมูล by keycloak

This commit is contained in:
Kittapath 2024-05-23 16:44:37 +07:00
parent f6bcd35e14
commit ff0be7af48
22 changed files with 633 additions and 137 deletions

View file

@ -29,6 +29,27 @@ export class ProfileDutyController extends Controller {
private dutyRepository = AppDataSource.getRepository(ProfileDuty);
private dutyHistoryRepository = AppDataSource.getRepository(ProfileDutyHistory);
@Get("user")
public async getDutyUser(@Request() request: { user: Record<string, any> }) {
const profile = await this.profileRepository.findOneBy({ keycloak: request.user.sub });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const lists = await this.dutyRepository.find({
where: { profileId: profile.id },
select: [
"id",
"dateStart",
"dateEnd",
"reference",
"detail",
"refCommandNo",
"refCommandDate",
],
});
return new HttpSuccess(lists);
}
@Get("{profileId}")
@Example({
status: 200,