add api find dna by keycloak
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s
This commit is contained in:
parent
dbc46e2fb9
commit
39a07482cd
1 changed files with 836 additions and 767 deletions
|
|
@ -280,6 +280,75 @@ export class OrganizationController extends Controller {
|
||||||
return new HttpSuccess(requestBody);
|
return new HttpSuccess(requestBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API สร้างแบบร่างโครงสร้าง
|
||||||
|
*
|
||||||
|
* @summary ORG_022 - สร้างโครงสร้างใหม่ #23
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("finddna-by-keycloak/{keycloakId}")
|
||||||
|
async FindDnaOrgByKeycloakId(
|
||||||
|
@Path() keycloakId: string
|
||||||
|
) {
|
||||||
|
|
||||||
|
let reply: any;
|
||||||
|
|
||||||
|
const profileByKeycloak: any = await this.profileRepo.findOne({
|
||||||
|
where: { keycloak: keycloakId },
|
||||||
|
select: ["id", "keycloak"]
|
||||||
|
})
|
||||||
|
|
||||||
|
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||||
|
select: ["id"],
|
||||||
|
where: {
|
||||||
|
orgRevisionIsDraft: false,
|
||||||
|
orgRevisionIsCurrent: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const posMaster = await AppDataSource.getRepository(PosMaster)
|
||||||
|
.createQueryBuilder("pos")
|
||||||
|
.leftJoin("pos.orgRoot", "orgRoot")
|
||||||
|
.leftJoin("pos.orgChild1", "orgChild1")
|
||||||
|
.leftJoin("pos.orgChild2", "orgChild2")
|
||||||
|
.leftJoin("pos.orgChild3", "orgChild3")
|
||||||
|
.leftJoin("pos.orgChild4", "orgChild4")
|
||||||
|
.where("pos.current_holderId = :holderId", {
|
||||||
|
holderId: profileByKeycloak.id,
|
||||||
|
})
|
||||||
|
.andWhere("pos.orgRevisionId = :revId", {
|
||||||
|
revId: orgRevision?.id,
|
||||||
|
})
|
||||||
|
.select([
|
||||||
|
"pos.id",
|
||||||
|
"orgRoot.ancestorDNA as rootDnaId",
|
||||||
|
"orgChild1.ancestorDNA as child1DnaId",
|
||||||
|
"orgChild2.ancestorDNA as child2DnaId",
|
||||||
|
"orgChild3.ancestorDNA as child3DnaId",
|
||||||
|
"orgChild4.ancestorDNA as child4DnaId",
|
||||||
|
])
|
||||||
|
.getRawOne();
|
||||||
|
|
||||||
|
if (!posMaster) {
|
||||||
|
reply = {
|
||||||
|
rootDnaId: null,
|
||||||
|
child1DnaId: null,
|
||||||
|
child2DnaId: null,
|
||||||
|
child3DnaId: null,
|
||||||
|
child4DnaId: null,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
reply = {
|
||||||
|
rootDnaId: posMaster.rootDnaId,
|
||||||
|
child1DnaId: posMaster.child1DnaId,
|
||||||
|
child2DnaId: posMaster.child2DnaId,
|
||||||
|
child3DnaId: posMaster.child3DnaId,
|
||||||
|
child4DnaId: posMaster.child4DnaId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return new HttpSuccess(reply);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API เช็คสถานะโครงสร้างว่าส่งคนไปออกคำสั่งหรือไม่
|
* API เช็คสถานะโครงสร้างว่าส่งคนไปออกคำสั่งหรือไม่
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue