add function find commander
This commit is contained in:
parent
aaf2ad880d
commit
d6afe2c8f7
1 changed files with 72 additions and 1 deletions
|
|
@ -1265,6 +1265,7 @@ export class WorkflowController extends Controller {
|
|||
refId: string[];
|
||||
},
|
||||
) {
|
||||
|
||||
const _posMaster = await this.posMasterRepo.find({
|
||||
where: {
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
|
|
@ -1272,6 +1273,7 @@ export class WorkflowController extends Controller {
|
|||
},
|
||||
select: ["orgRootId", "orgChild1Id", "orgChild2Id", "orgChild3Id", "orgChild4Id"],
|
||||
});
|
||||
|
||||
const _data: any = _posMaster.map((x) => ({
|
||||
orgRootId: x.orgRootId,
|
||||
// orgChild1Id: x.orgChild1Id,
|
||||
|
|
@ -1282,11 +1284,12 @@ export class WorkflowController extends Controller {
|
|||
current_holder: Not(IsNull()),
|
||||
posMasterAssigns: { assignId: system.trim().toUpperCase() },
|
||||
}));
|
||||
|
||||
const posMaster = await this.posMasterRepo.find({
|
||||
where: _data,
|
||||
relations: ["current_holder"],
|
||||
});
|
||||
|
||||
|
||||
const data = posMaster.map((x) => ({
|
||||
id: x.current_holder.id,
|
||||
citizenId: x.current_holder.citizenId,
|
||||
|
|
@ -1294,6 +1297,74 @@ export class WorkflowController extends Controller {
|
|||
firstName: x.current_holder.firstName,
|
||||
lastName: x.current_holder.lastName,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(data);
|
||||
}
|
||||
/**
|
||||
* API หา กจ ตามระบบด้วย keycloak
|
||||
*
|
||||
* @summary หา กจ ตามระบบด้วย keycloak
|
||||
*
|
||||
*/
|
||||
@Post("find/director-with-keycloak/{system}")
|
||||
async getProfileDirectorByKeycloakIdSystem(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() system: string,
|
||||
@Body()
|
||||
body: {
|
||||
refId: string[];
|
||||
},
|
||||
) {
|
||||
|
||||
const profileWithKc = await this.profileRepo.find({
|
||||
where:{
|
||||
keycloak: In(body.refId)
|
||||
}
|
||||
})
|
||||
|
||||
const profileIds = profileWithKc.map((p) => p.id);
|
||||
|
||||
const _posMaster = await this.posMasterRepo.find({
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
current_holderId: In(profileIds),
|
||||
},
|
||||
select: [
|
||||
"orgRootId",
|
||||
"orgChild1Id",
|
||||
"orgChild2Id",
|
||||
"orgChild3Id",
|
||||
"orgChild4Id",
|
||||
],
|
||||
})
|
||||
|
||||
const _data: any = _posMaster.map((x) => ({
|
||||
orgRootId: x.orgRootId,
|
||||
// orgChild1Id: x.orgChild1Id,
|
||||
// orgChild2Id: x.orgChild2Id,
|
||||
// orgChild3Id: x.orgChild3Id,
|
||||
// orgChild4Id: x.orgChild4Id,
|
||||
// isDirector: true,
|
||||
current_holder: Not(IsNull()),
|
||||
posMasterAssigns: { assignId: system.trim().toUpperCase() },
|
||||
}));
|
||||
|
||||
const posMaster = await this.posMasterRepo.find({
|
||||
where: _data,
|
||||
relations: ["current_holder"],
|
||||
});
|
||||
|
||||
const data = posMaster.map((x) => ({
|
||||
id: x.current_holder.id,
|
||||
citizenId: x.current_holder.citizenId,
|
||||
prefix: x.current_holder.prefix,
|
||||
firstName: x.current_holder.firstName,
|
||||
lastName: x.current_holder.lastName,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue