no message

This commit is contained in:
kittapath 2025-02-06 17:18:29 +07:00
parent 72fd4d62e3
commit 3b3352009c
2 changed files with 101 additions and 54 deletions

View file

@ -1472,50 +1472,99 @@ export class ProfileController extends Controller {
pageSize: number; pageSize: number;
}, },
) { ) {
if (body.isAct == true) { let posMaster = await this.posMasterRepo.findOne({
const 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: { where: {
current_holder: { keycloak: request.user.sub }, orgRoot: { isDeputy: true },
orgChild1Id: IsNull(),
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, 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 = { // let condition: any = {
orgRootId: posMaster.orgRootId,
id: Not(posMaster.current_holderId || ""),
};
// let conditionNow: any = {
// orgRootId: posMaster.orgRootId, // orgRootId: posMaster.orgRootId,
// orgChild1Id: posMaster.orgChild1Id, // id: Not(posMaster.current_holderId || ""),
// orgChild2Id: posMaster.orgChild2Id,
// orgChild3Id: posMaster.orgChild3Id,
// orgChild4Id: posMaster.orgChild4Id,
// id: Not(posMaster.current_holderId),
// }; // };
// if (posMaster.orgChild1Id == null) { // // let conditionNow: any = {
// condition.orgRootId = null; // // orgRootId: posMaster.orgRootId,
// } else if (posMaster.orgChild2Id == null) { // // orgChild1Id: posMaster.orgChild1Id,
// condition.orgChild1Id = null; // // orgChild2Id: posMaster.orgChild2Id,
// } else if (posMaster.orgChild3Id == null) { // // orgChild3Id: posMaster.orgChild3Id,
// condition.orgChild2Id = null; // // orgChild4Id: posMaster.orgChild4Id,
// } else if (posMaster.orgChild4Id == null) { // // id: Not(posMaster.current_holderId),
// condition.orgChild3Id = null; // // };
// } else { // // if (posMaster.orgChild1Id == null) {
// condition.orgChild4Id = 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) const [lists, total] = await AppDataSource.getRepository(viewDirectorActing)
.createQueryBuilder("viewDirectorActing") .createQueryBuilder("viewDirectorActing")
.andWhere(condition) // .andWhere(condition)
// .andWhere( .andWhere(
// new Brackets((qb) => { new Brackets((qb) => {
// qb.orWhere(condition).orWhere(conditionNow); qb.orWhere(condition).orWhere(conditionNow);
// }), }),
// ) )
.andWhere( .andWhere(
new Brackets((qb) => { new Brackets((qb) => {
qb.orWhere( qb.orWhere(
@ -1565,18 +1614,18 @@ export class ProfileController extends Controller {
.getManyAndCount(); .getManyAndCount();
return new HttpSuccess({ data: lists, total }); return new HttpSuccess({ data: lists, total });
} else { } else {
const posMaster = await this.posMasterRepo.findOne({ // const posMaster = await this.posMasterRepo.findOne({
where: { // where: {
current_holder: { keycloak: request.user.sub }, // current_holder: { keycloak: request.user.sub },
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, // orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
}, // },
}); // });
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง"); // if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง");
let condition: any = { // let condition: any = {
orgRootId: posMaster.orgRootId, // orgRootId: posMaster.orgRootId,
id: Not(posMaster.current_holderId || ""), // id: Not(posMaster.current_holderId || ""),
}; // };
// let conditionNow: any = { // let conditionNow: any = {
// orgRootId: posMaster.orgRootId, // orgRootId: posMaster.orgRootId,
// orgChild1Id: posMaster.orgChild1Id, // orgChild1Id: posMaster.orgChild1Id,
@ -1596,13 +1645,13 @@ export class ProfileController extends Controller {
// } else { // } else {
// condition.orgChild4Id = null; // condition.orgChild4Id = null;
// } // }
if (body.isDirector == true) { // if (body.isDirector == true) {
condition.isDirector = true; // condition.isDirector = true;
// conditionNow.isDirector = true; // // conditionNow.isDirector = true;
} // }
const [lists, total] = await AppDataSource.getRepository(viewDirector) const [lists, total] = await AppDataSource.getRepository(viewDirector)
.createQueryBuilder("viewDirector") .createQueryBuilder("viewDirector")
.andWhere(condition) // .andWhere(condition)
// .andWhere( // .andWhere(
// new Brackets((qb) => { // new Brackets((qb) => {
// qb.orWhere(condition).orWhere(conditionNow); // qb.orWhere(condition).orWhere(conditionNow);
@ -1724,8 +1773,6 @@ export class ProfileController extends Controller {
condition.isDirector = true; condition.isDirector = true;
conditionNow.isDirector = true; conditionNow.isDirector = true;
} }
console.log(condition);
console.log(conditionNow);
if (body.isAct == true) { if (body.isAct == true) {
const [lists, total] = await AppDataSource.getRepository(viewDirectorActing) const [lists, total] = await AppDataSource.getRepository(viewDirectorActing)
.createQueryBuilder("viewDirectorActing") .createQueryBuilder("viewDirectorActing")

View file

@ -49,7 +49,7 @@ import { ViewColumn, ViewEntity } from "typeorm";
AND ( AND (
(\`acting\`.\`orgChild4Id\` IS NULL AND \`posMaster\`.\`orgChild4Id\` IS NULL) (\`acting\`.\`orgChild4Id\` IS NULL AND \`posMaster\`.\`orgChild4Id\` IS NULL)
OR (\`acting\`.\`orgChild4Id\` = \`posMaster\`.\`orgChild4Id\`) OR (\`acting\`.\`orgChild4Id\` = \`posMaster\`.\`orgChild4Id\`)
) ) LIMIT 1
) AS \`actFullNameId\`, ) AS \`actFullNameId\`,
( (
SELECT \`actFullName\` SELECT \`actFullName\`
@ -71,7 +71,7 @@ import { ViewColumn, ViewEntity } from "typeorm";
AND ( AND (
(\`acting\`.\`orgChild4Id\` IS NULL AND \`posMaster\`.\`orgChild4Id\` IS NULL) (\`acting\`.\`orgChild4Id\` IS NULL AND \`posMaster\`.\`orgChild4Id\` IS NULL)
OR (\`acting\`.\`orgChild4Id\` = \`posMaster\`.\`orgChild4Id\`) OR (\`acting\`.\`orgChild4Id\` = \`posMaster\`.\`orgChild4Id\`)
) ) LIMIT 1
) AS \`actFullName\` ) AS \`actFullName\`
FROM FROM