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

@ -35,6 +35,21 @@ export class ProfileAbilityEmployeeController extends Controller {
private profileAbilityRepo = AppDataSource.getRepository(ProfileAbility);
private profileAbilityHistoryRepo = AppDataSource.getRepository(ProfileAbilityHistory);
@Get("user")
public async detailProfileAbilityUser(@Request() request: { user: Record<string, any> }) {
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const getProfileAbilityId = await this.profileAbilityRepo.find({
where: { profileEmployeeId: profile.id },
});
if (!getProfileAbilityId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(getProfileAbilityId);
}
@Get("{profileEmployeeId}")
@Example({
status: 200,
@ -181,7 +196,7 @@ export class ProfileAbilityEmployeeController extends Controller {
if (result.affected == undefined || result.affected <= 0) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess();
}
}