no message
This commit is contained in:
parent
72fd4d62e3
commit
3b3352009c
2 changed files with 101 additions and 54 deletions
|
|
@ -1472,50 +1472,99 @@ export class ProfileController extends Controller {
|
|||
pageSize: number;
|
||||
},
|
||||
) {
|
||||
if (body.isAct == true) {
|
||||
const posMaster = await this.posMasterRepo.findOne({
|
||||
let posMaster = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
current_holder: { keycloak: request.user.sub },
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
},
|
||||
relations: ["current_holder", "current_holder.posLevel"],
|
||||
});
|
||||
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง");
|
||||
if ((posMaster?.current_holder?.posLevel?.posLevelAuthority ?? null) == "DEPUTY") {
|
||||
posMaster = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
current_holder: { keycloak: request.user.sub },
|
||||
orgRoot: { isDeputy: true },
|
||||
orgChild1Id: IsNull(),
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
},
|
||||
});
|
||||
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง");
|
||||
return new HttpSuccess({ data: [], total: 0 });
|
||||
} else if ((posMaster?.current_holder?.posLevel?.posLevelAuthority ?? null) == "GOVERNOR") {
|
||||
return new HttpSuccess({ data: [], total: 0 });
|
||||
}
|
||||
let condition: any = {
|
||||
orgRootId: posMaster.orgRootId,
|
||||
id: Not(posMaster.current_holderId || ""),
|
||||
};
|
||||
let conditionNow: any = {
|
||||
orgRootId: posMaster.orgRootId ?? IsNull(),
|
||||
orgChild1Id: posMaster.orgChild1Id ?? IsNull(),
|
||||
orgChild2Id: posMaster.orgChild2Id ?? IsNull(),
|
||||
orgChild3Id: posMaster.orgChild3Id ?? IsNull(),
|
||||
orgChild4Id: posMaster.orgChild4Id ?? IsNull(),
|
||||
id: Not(posMaster.current_holderId),
|
||||
};
|
||||
if (
|
||||
posMaster.orgRootId == null ||
|
||||
posMaster.orgChild1Id == null ||
|
||||
posMaster.orgChild2Id == null
|
||||
) {
|
||||
condition.orgChild1Id = IsNull();
|
||||
} else if (posMaster.orgChild3Id == null) {
|
||||
condition.orgChild2Id = IsNull();
|
||||
} else if (posMaster.orgChild4Id == null) {
|
||||
condition.orgChild3Id = IsNull();
|
||||
} else if (posMaster.orgChild4Id != null) {
|
||||
condition.orgChild4Id = IsNull();
|
||||
}
|
||||
if (body.isDirector == true) {
|
||||
condition.isDirector = true;
|
||||
conditionNow.isDirector = true;
|
||||
}
|
||||
if (body.isAct == true) {
|
||||
// const posMaster = await this.posMasterRepo.findOne({
|
||||
// where: {
|
||||
// current_holder: { keycloak: request.user.sub },
|
||||
// orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
// },
|
||||
// });
|
||||
// if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง");
|
||||
|
||||
let condition: any = {
|
||||
orgRootId: posMaster.orgRootId,
|
||||
id: Not(posMaster.current_holderId || ""),
|
||||
};
|
||||
// let conditionNow: any = {
|
||||
// let condition: any = {
|
||||
// orgRootId: posMaster.orgRootId,
|
||||
// orgChild1Id: posMaster.orgChild1Id,
|
||||
// orgChild2Id: posMaster.orgChild2Id,
|
||||
// orgChild3Id: posMaster.orgChild3Id,
|
||||
// orgChild4Id: posMaster.orgChild4Id,
|
||||
// id: Not(posMaster.current_holderId),
|
||||
// id: Not(posMaster.current_holderId || ""),
|
||||
// };
|
||||
// if (posMaster.orgChild1Id == null) {
|
||||
// condition.orgRootId = null;
|
||||
// } else if (posMaster.orgChild2Id == null) {
|
||||
// condition.orgChild1Id = null;
|
||||
// } else if (posMaster.orgChild3Id == null) {
|
||||
// condition.orgChild2Id = null;
|
||||
// } else if (posMaster.orgChild4Id == null) {
|
||||
// condition.orgChild3Id = null;
|
||||
// } else {
|
||||
// condition.orgChild4Id = null;
|
||||
// // let conditionNow: any = {
|
||||
// // orgRootId: posMaster.orgRootId,
|
||||
// // orgChild1Id: posMaster.orgChild1Id,
|
||||
// // orgChild2Id: posMaster.orgChild2Id,
|
||||
// // orgChild3Id: posMaster.orgChild3Id,
|
||||
// // orgChild4Id: posMaster.orgChild4Id,
|
||||
// // id: Not(posMaster.current_holderId),
|
||||
// // };
|
||||
// // if (posMaster.orgChild1Id == null) {
|
||||
// // condition.orgRootId = null;
|
||||
// // } else if (posMaster.orgChild2Id == null) {
|
||||
// // condition.orgChild1Id = null;
|
||||
// // } else if (posMaster.orgChild3Id == null) {
|
||||
// // condition.orgChild2Id = null;
|
||||
// // } else if (posMaster.orgChild4Id == null) {
|
||||
// // condition.orgChild3Id = null;
|
||||
// // } else {
|
||||
// // condition.orgChild4Id = null;
|
||||
// // }
|
||||
// if (body.isDirector == true) {
|
||||
// condition.isDirector = true;
|
||||
// // conditionNow.isDirector = true;
|
||||
// }
|
||||
if (body.isDirector == true) {
|
||||
condition.isDirector = true;
|
||||
// conditionNow.isDirector = true;
|
||||
}
|
||||
const [lists, total] = await AppDataSource.getRepository(viewDirectorActing)
|
||||
.createQueryBuilder("viewDirectorActing")
|
||||
.andWhere(condition)
|
||||
// .andWhere(
|
||||
// new Brackets((qb) => {
|
||||
// qb.orWhere(condition).orWhere(conditionNow);
|
||||
// }),
|
||||
// )
|
||||
// .andWhere(condition)
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere(condition).orWhere(conditionNow);
|
||||
}),
|
||||
)
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere(
|
||||
|
|
@ -1565,18 +1614,18 @@ export class ProfileController extends Controller {
|
|||
.getManyAndCount();
|
||||
return new HttpSuccess({ data: lists, total });
|
||||
} else {
|
||||
const posMaster = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
current_holder: { keycloak: request.user.sub },
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
},
|
||||
});
|
||||
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง");
|
||||
// const posMaster = await this.posMasterRepo.findOne({
|
||||
// where: {
|
||||
// current_holder: { keycloak: request.user.sub },
|
||||
// orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
// },
|
||||
// });
|
||||
// if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง");
|
||||
|
||||
let condition: any = {
|
||||
orgRootId: posMaster.orgRootId,
|
||||
id: Not(posMaster.current_holderId || ""),
|
||||
};
|
||||
// let condition: any = {
|
||||
// orgRootId: posMaster.orgRootId,
|
||||
// id: Not(posMaster.current_holderId || ""),
|
||||
// };
|
||||
// let conditionNow: any = {
|
||||
// orgRootId: posMaster.orgRootId,
|
||||
// orgChild1Id: posMaster.orgChild1Id,
|
||||
|
|
@ -1596,13 +1645,13 @@ export class ProfileController extends Controller {
|
|||
// } else {
|
||||
// condition.orgChild4Id = null;
|
||||
// }
|
||||
if (body.isDirector == true) {
|
||||
condition.isDirector = true;
|
||||
// conditionNow.isDirector = true;
|
||||
}
|
||||
// if (body.isDirector == true) {
|
||||
// condition.isDirector = true;
|
||||
// // conditionNow.isDirector = true;
|
||||
// }
|
||||
const [lists, total] = await AppDataSource.getRepository(viewDirector)
|
||||
.createQueryBuilder("viewDirector")
|
||||
.andWhere(condition)
|
||||
// .andWhere(condition)
|
||||
// .andWhere(
|
||||
// new Brackets((qb) => {
|
||||
// qb.orWhere(condition).orWhere(conditionNow);
|
||||
|
|
@ -1724,8 +1773,6 @@ export class ProfileController extends Controller {
|
|||
condition.isDirector = true;
|
||||
conditionNow.isDirector = true;
|
||||
}
|
||||
console.log(condition);
|
||||
console.log(conditionNow);
|
||||
if (body.isAct == true) {
|
||||
const [lists, total] = await AppDataSource.getRepository(viewDirectorActing)
|
||||
.createQueryBuilder("viewDirectorActing")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue