ค้นหาเฉพาะกิ่ง

This commit is contained in:
kittapath 2024-09-04 12:09:23 +07:00
parent 1d0b35983b
commit af5cd2d17e
3 changed files with 53 additions and 22 deletions

View file

@ -2634,7 +2634,9 @@ export class ProfileController extends Controller {
@Query() isRetire?: boolean,
@Query() node?: number,
@Query() nodeId?: string,
@Query() isAll?: boolean,
) {
let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_OFFICER");
let queryLike =
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
if (searchField == "citizenId") {
@ -2652,18 +2654,23 @@ export class ProfileController extends Controller {
) LIKE :keyword`;
}
let nodeCondition = "1=1";
let nodeAll = "";
if (node === 0 && nodeId) {
nodeCondition = "current_holders.orgRootId = :nodeId";
if (isAll == true) nodeAll = " AND current_holders.orgChild1Id IS NULL";
} else if (node === 1 && nodeId) {
nodeCondition = "current_holders.orgChild1Id = :nodeId";
if (isAll == true) nodeAll = " AND current_holders.orgChild2Id IS NULL";
} else if (node === 2 && nodeId) {
nodeCondition = "current_holders.orgChild2Id = :nodeId";
if (isAll == true) nodeAll = " AND current_holders.orgChild3Id IS NULL";
} else if (node === 3 && nodeId) {
nodeCondition = "current_holders.orgChild3Id = :nodeId";
if (isAll == true) nodeAll = " AND current_holders.orgChild4Id IS NULL";
} else if (node === 4 && nodeId) {
nodeCondition = "current_holders.orgChild4Id = :nodeId";
}
let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_OFFICER");
nodeCondition = nodeCondition + nodeAll;
const [record, total] = await this.profileRepo
.createQueryBuilder("profile")
.leftJoinAndSelect("profile.posLevel", "posLevel")