Merge branch 'develop' into adiDev
This commit is contained in:
commit
061cb2c835
1 changed files with 97 additions and 9 deletions
|
|
@ -60,16 +60,103 @@ export class OrganizationDotnetController extends Controller {
|
||||||
citizenId?: string | null;
|
citizenId?: string | null;
|
||||||
firstName?: string | null;
|
firstName?: string | null;
|
||||||
lastName?: string | null;
|
lastName?: string | null;
|
||||||
|
role?: string | null;
|
||||||
|
nodeId?: string | null;
|
||||||
|
node?: number | null;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const profileRepository = AppDataSource.getRepository(Profile);
|
// const profileRepository = AppDataSource.getRepository(Profile);
|
||||||
const queryBuilder = profileRepository
|
// const queryBuilder = profileRepository
|
||||||
|
// .createQueryBuilder("profile")
|
||||||
|
// .leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
|
// .leftJoinAndSelect("profile.posType", "posType")
|
||||||
|
// if (body.citizenId || body.firstName || body.lastName) {
|
||||||
|
// queryBuilder.where(
|
||||||
|
// new Brackets((qb) => {
|
||||||
|
// if (body.citizenId) {
|
||||||
|
// qb.orWhere("profile.citizenId LIKE :citizenId", { citizenId: `%${body.citizenId}%` });
|
||||||
|
// }
|
||||||
|
// if (body.firstName) {
|
||||||
|
// qb.orWhere("profile.firstName LIKE :firstName", { firstName: `%${body.firstName}%` });
|
||||||
|
// }
|
||||||
|
// if (body.lastName) {
|
||||||
|
// qb.orWhere("profile.lastName LIKE :lastName", { lastName: `%${body.lastName}%` });
|
||||||
|
// }
|
||||||
|
// }),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// const profiles = await queryBuilder.getMany();
|
||||||
|
let condition = "1=1";
|
||||||
|
let conditionParams = {};
|
||||||
|
if (body.role === "CHILD") {
|
||||||
|
switch (body.node) {
|
||||||
|
case 0:
|
||||||
|
condition = "orgRoot.ancestorDNA = :nodeId";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
condition = "orgChild1.ancestorDNA = :nodeId";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
condition = "orgChild2.ancestorDNA = :nodeId";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
condition = "orgChild3.ancestorDNA = :nodeId";
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
condition = "orgChild4.ancestorDNA = :nodeId";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
condition = "1=1";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
conditionParams = { nodeId: body.nodeId };
|
||||||
|
}
|
||||||
|
else if (body.role === "ROOT") {
|
||||||
|
condition = "orgRoot.ancestorDNA = :nodeId";
|
||||||
|
conditionParams = { nodeId: body.nodeId };
|
||||||
|
}
|
||||||
|
else if (body.role === "NORMAL") {
|
||||||
|
switch (body.node) {
|
||||||
|
case 0:
|
||||||
|
condition = "orgRoot.ancestorDNA = :nodeId AND current_holders.orgChild1 IS NULL";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
condition = "orgChild1.ancestorDNA = :nodeId AND current_holders.orgChild2 IS NULL";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
condition = "orgChild2.ancestorDNA = :nodeId AND current_holders.orgChild3 IS NULL";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
condition = "orgChild3.ancestorDNA = :nodeId AND current_holders.orgChild4 IS NULL";
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
condition = "orgChild4.ancestorDNA = :nodeId";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
condition = "1=1";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
conditionParams = { nodeId: body.nodeId };
|
||||||
|
}
|
||||||
|
|
||||||
|
const findRevision = await this.orgRevisionRepo.findOne({
|
||||||
|
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }
|
||||||
|
});
|
||||||
|
if (!findRevision) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||||
|
}
|
||||||
|
const profiles = await this.profileRepo
|
||||||
.createQueryBuilder("profile")
|
.createQueryBuilder("profile")
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
.leftJoinAndSelect("profile.posType", "posType");
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
if (body.citizenId || body.firstName || body.lastName) {
|
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
||||||
queryBuilder.where(
|
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||||
|
.where("current_holders.orgRevisionId = :orgRevisionId", { orgRevisionId: findRevision.id })
|
||||||
|
.andWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
if (body.citizenId) {
|
if (body.citizenId) {
|
||||||
qb.orWhere("profile.citizenId LIKE :citizenId", { citizenId: `%${body.citizenId}%` });
|
qb.orWhere("profile.citizenId LIKE :citizenId", { citizenId: `%${body.citizenId}%` });
|
||||||
|
|
@ -81,9 +168,10 @@ export class OrganizationDotnetController extends Controller {
|
||||||
qb.orWhere("profile.lastName LIKE :lastName", { lastName: `%${body.lastName}%` });
|
qb.orWhere("profile.lastName LIKE :lastName", { lastName: `%${body.lastName}%` });
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
)
|
||||||
}
|
.andWhere(condition, conditionParams)
|
||||||
const profiles = await queryBuilder.getMany();
|
.getMany()
|
||||||
|
|
||||||
return new HttpSuccess(profiles);
|
return new HttpSuccess(profiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue