get ข้อมูล by keycloak
This commit is contained in:
parent
f6bcd35e14
commit
ff0be7af48
22 changed files with 633 additions and 137 deletions
|
|
@ -33,6 +33,18 @@ export class ProfileChildrenController extends Controller {
|
|||
private childrenRepository = AppDataSource.getRepository(ProfileChildren);
|
||||
private childrenHistoryRepository = AppDataSource.getRepository(ProfileChildrenHistory);
|
||||
|
||||
@Get("user")
|
||||
public async getChildrenUser(@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.childrenRepository.find({
|
||||
where: { profileId: profile.id },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("{profileId}")
|
||||
public async getChildren(@Path() profileId: string) {
|
||||
const lists = await this.childrenRepository.find({
|
||||
|
|
@ -67,9 +79,9 @@ export class ProfileChildrenController extends Controller {
|
|||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
data.childrenCitizenId = Extension.CheckCitizen(String(data.childrenCitizenId));
|
||||
data.childrenCitizenId = Extension.CheckCitizen(String(data.childrenCitizenId));
|
||||
await this.childrenRepository.save(data);
|
||||
if(data){
|
||||
if (data) {
|
||||
const history: ProfileChildrenHistory = Object.assign(new ProfileChildrenHistory(), {
|
||||
profileChildrenId: data.id,
|
||||
childrenCareer: data.childrenCareer,
|
||||
|
|
@ -102,16 +114,15 @@ export class ProfileChildrenController extends Controller {
|
|||
Object.assign(record, body);
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
|
||||
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
|
||||
history.profileChildrenId = record.id;
|
||||
history.childrenCareer = record.childrenCareer;
|
||||
history.childrenFirstName = record.childrenFirstName;
|
||||
history.childrenLastName = record.childrenLastName;
|
||||
history.childrenPrefix = record.childrenPrefix;
|
||||
history.childrenPrefix = record.childrenPrefix;
|
||||
history.childrenLive = record.childrenLive;
|
||||
history.childrenCitizenId = record.childrenCitizenId;
|
||||
history.lastUpdateUserId = req.user.sub,
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
(history.lastUpdateUserId = req.user.sub), (history.lastUpdateFullName = req.user.name);
|
||||
await Promise.all([
|
||||
this.childrenRepository.save(record),
|
||||
this.childrenHistoryRepository.save(history),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue