api history/user

This commit is contained in:
AdisakKanthawilang 2024-05-24 13:13:52 +07:00
parent 63d357ea30
commit 7b480b1247
2 changed files with 65 additions and 15 deletions

View file

@ -570,6 +570,31 @@ export class ProfileController extends Controller {
return new HttpSuccess(profile); return new HttpSuccess(profile);
} }
/**
* API
*
* @summary
*
* @param {string} id Id
*/
@Get("history/user")
async getHistoryProfileByUser(@Request() request: RequestWithUser) {
const historyProfile = await this.profileHistoryRepo.find({
relations: {
posLevel: true,
posType: true,
},
where: { keycloak: request.user.sub },
order: {
createdAt:"ASC",
}
});
if (!historyProfile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess(historyProfile);
}
/** /**
* API * API
* *

View file

@ -392,6 +392,31 @@ export class ProfileEmployeeController extends Controller {
return new HttpSuccess(profile); return new HttpSuccess(profile);
} }
/**
* API
*
* @summary
*
* @param {string} id Id
*/
@Get("history/user")
async getHistoryProfileByUser(@Request() request: RequestWithUser) {
const historyProfile = await this.profileHistoryRepo.find({
relations: {
posLevel: true,
posType: true,
},
where: { keycloak: request.user.sub },
order: {
createdAt: "ASC",
},
});
if (!historyProfile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess(historyProfile);
}
/** /**
* API * API
* *
@ -998,22 +1023,22 @@ export class ProfileEmployeeController extends Controller {
} }
} }
const rootHolder = item.current_holders?.find( const rootHolder = item.current_holders?.find(
(x) => x.orgRevisionId == findRevision.id, (x) => x.orgRevisionId == findRevision.id,
)?.orgRoot; )?.orgRoot;
const child1Holder = item.current_holders?.find( const child1Holder = item.current_holders?.find(
(x) => x.orgRevisionId == findRevision.id, (x) => x.orgRevisionId == findRevision.id,
)?.orgChild1; )?.orgChild1;
const child2Holder = item.current_holders?.find( const child2Holder = item.current_holders?.find(
(x) => x.orgRevisionId == findRevision.id, (x) => x.orgRevisionId == findRevision.id,
)?.orgChild2; )?.orgChild2;
const child3Holder = item.current_holders?.find( const child3Holder = item.current_holders?.find(
(x) => x.orgRevisionId == findRevision.id, (x) => x.orgRevisionId == findRevision.id,
)?.orgChild3; )?.orgChild3;
const child4Holder = item.current_holders?.find( const child4Holder = item.current_holders?.find(
(x) => x.orgRevisionId == findRevision.id, (x) => x.orgRevisionId == findRevision.id,
)?.orgChild4; )?.orgChild4;
return { return {
id: item.id, id: item.id,
prefix: item.prefix, prefix: item.prefix,