This commit is contained in:
Bright 2024-11-25 21:02:43 +07:00
parent 859c61aa99
commit 542df70eb7
3 changed files with 22 additions and 4 deletions

View file

@ -126,6 +126,7 @@ export class PermissionOrgController extends Controller {
const findRevision = await this.orgRevisionRepository.findOne({
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
});
const orgRevisionId = findRevision?.id;
if (!findRevision) {
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
}
@ -138,16 +139,19 @@ export class PermissionOrgController extends Controller {
.leftJoinAndSelect("profile.current_holders", "current_holders")
.leftJoinAndSelect("current_holders.positions", "positions")
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
.leftJoinAndSelect("current_holders.orgRevision", "orgRevision")
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
.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})
.andWhere(
new Brackets((qb) => {
qb.andWhere(`current_holders.orgRevisionId = :orgRevisionId`, {
orgRevisionId: findRevision.id,
}).andWhere(
// qb.andWhere(`current_holders.orgRevision = :orgRevisionId`, {
// orgRevisionId: findRevision.id,
// })
qb.andWhere(
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
? queryLike
: "1=1",