diff --git a/src/controllers/PermissionOrgController.ts b/src/controllers/PermissionOrgController.ts index 7bdfbbe3..d4d3f4c3 100644 --- a/src/controllers/PermissionOrgController.ts +++ b/src/controllers/PermissionOrgController.ts @@ -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", diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 3a4ec96f..6ff78f92 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -1591,6 +1591,18 @@ export class PositionController extends Controller { .take(body.pageSize) .getManyAndCount(); + //serch name สิทธิ์ + // if(posMaster.length == 0 && body.keyword != null && body.keyword != "") { + // let _authRole:any; + // let _masterIdRole:any + // _authRole = await this.authRoleRepo.find({ + // where: { + // roleName: Like(`%${body.keyword}%`), + // }, + // relations: ["posMasters"] + // }); + // _masterIdRole = [...new Set(_authRole.map((x: any) => x.posMasters.map((y: any) => y.id)).flat())]; + // } //แก้ค้นหา let _position: any[] = []; let x: any = null; diff --git a/src/controllers/ProfileGovernmentEmployeeController.ts b/src/controllers/ProfileGovernmentEmployeeController.ts index 5515f220..2d5cc270 100644 --- a/src/controllers/ProfileGovernmentEmployeeController.ts +++ b/src/controllers/ProfileGovernmentEmployeeController.ts @@ -103,7 +103,9 @@ export class ProfileGovernmentEmployeeController extends Controller { const data = { org: org, //สังกัด position: record.position, //ตำแหน่ง - posLevel: record.posLevel == null ? null : record.posLevel.posLevelName, //ระดับ + posLevel: record.posType == null && record.posLevel == null + ? null + : `${record.posType.posTypeShortName}${record.posLevel.posLevelName}`, //ระดับ posMasterNo: posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`, //เลขที่ตำแหน่ง posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate),