search retire
This commit is contained in:
parent
a03a53954c
commit
5f53769292
1 changed files with 275 additions and 256 deletions
|
|
@ -5478,82 +5478,82 @@ export class ProfileController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* API ค้นหาและแสดงผู้พ้นจากราชการ ข้าราชการ กทม. สามัญ
|
||||
*
|
||||
* @summary ค้นหาและแสดงผู้พ้นจากราชการ ข้าราชการ กทม. สามัญ จากตำแหน่ง
|
||||
*/
|
||||
@Get("profileLeave")
|
||||
@Example({
|
||||
status: 200,
|
||||
message: "สำเร็จ",
|
||||
result: {
|
||||
data: [
|
||||
{
|
||||
id: "ecb0b34c-037e-41f2-b95e-7e19f88b42ae",
|
||||
createdAt: "2024-03-24T12:39:12.105Z",
|
||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
||||
lastUpdatedAt: "2024-03-24T12:41:43.164Z",
|
||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
||||
createdFullName: "string",
|
||||
lastUpdateFullName: "string",
|
||||
rank: null,
|
||||
prefix: null,
|
||||
firstName: "Methapon",
|
||||
lastName: "Metanipat",
|
||||
citizenId: null,
|
||||
position: null,
|
||||
posLevelId: null,
|
||||
posTypeId: null,
|
||||
email: null,
|
||||
phone: null,
|
||||
keycloak: null,
|
||||
isProbation: false,
|
||||
dateRetire: null,
|
||||
birthDate: null,
|
||||
ethnicity: null,
|
||||
telephoneNumber: null,
|
||||
gender: null,
|
||||
relationship: null,
|
||||
bloodGroup: null,
|
||||
posLevel: null,
|
||||
posType: null,
|
||||
org: null,
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
},
|
||||
})
|
||||
async listProfileLeave(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query()
|
||||
searchField?: "firstName" | "lastName" | "fullName" | "citizenId" | "position" | "posNo",
|
||||
@Query() searchKeyword: string = "",
|
||||
@Query() posType?: string,
|
||||
@Query() posLevel?: string,
|
||||
@Query() yearLeave?: number,
|
||||
@Query() isProbation?: boolean,
|
||||
// @Query() isRetire?: boolean,
|
||||
@Query() node?: number,
|
||||
@Query() nodeId?: string,
|
||||
@Query() isAll?: boolean,
|
||||
@Query() retireType?: string,
|
||||
@Query() sortBy: string = "current_holders.posMasterNo",
|
||||
@Query() sort: "ASC" | "DESC" = "ASC",
|
||||
) {
|
||||
let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_OFFICER");
|
||||
let queryLike =
|
||||
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||
if (searchField == "citizenId") {
|
||||
queryLike = "profile.citizenId LIKE :keyword";
|
||||
} else if (searchField == "position") {
|
||||
queryLike = "profile.position LIKE :keyword";
|
||||
}
|
||||
@Get("profileLeave")
|
||||
@Example({
|
||||
status: 200,
|
||||
message: "สำเร็จ",
|
||||
result: {
|
||||
data: [
|
||||
{
|
||||
id: "ecb0b34c-037e-41f2-b95e-7e19f88b42ae",
|
||||
createdAt: "2024-03-24T12:39:12.105Z",
|
||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
||||
lastUpdatedAt: "2024-03-24T12:41:43.164Z",
|
||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
||||
createdFullName: "string",
|
||||
lastUpdateFullName: "string",
|
||||
rank: null,
|
||||
prefix: null,
|
||||
firstName: "Methapon",
|
||||
lastName: "Metanipat",
|
||||
citizenId: null,
|
||||
position: null,
|
||||
posLevelId: null,
|
||||
posTypeId: null,
|
||||
email: null,
|
||||
phone: null,
|
||||
keycloak: null,
|
||||
isProbation: false,
|
||||
dateRetire: null,
|
||||
birthDate: null,
|
||||
ethnicity: null,
|
||||
telephoneNumber: null,
|
||||
gender: null,
|
||||
relationship: null,
|
||||
bloodGroup: null,
|
||||
posLevel: null,
|
||||
posType: null,
|
||||
org: null,
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
},
|
||||
})
|
||||
async listProfileLeave(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query()
|
||||
searchField?: "firstName" | "lastName" | "fullName" | "citizenId" | "position" | "posNo",
|
||||
@Query() searchKeyword: string = "",
|
||||
@Query() posType?: string,
|
||||
@Query() posLevel?: string,
|
||||
@Query() yearLeave?: number,
|
||||
@Query() isProbation?: boolean,
|
||||
// @Query() isRetire?: boolean,
|
||||
@Query() node?: number,
|
||||
@Query() nodeId?: string,
|
||||
@Query() isAll?: boolean,
|
||||
@Query() retireType?: string,
|
||||
@Query() sortBy: string = "current_holders.posMasterNo",
|
||||
@Query() sort: "ASC" | "DESC" = "ASC",
|
||||
) {
|
||||
let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_OFFICER");
|
||||
let queryLike =
|
||||
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||
if (searchField == "citizenId") {
|
||||
queryLike = "profile.citizenId LIKE :keyword";
|
||||
} else if (searchField == "position") {
|
||||
queryLike = "profile.position LIKE :keyword";
|
||||
}
|
||||
// else if (searchField == "posNo") {
|
||||
// queryLike = `
|
||||
// CASE
|
||||
// CASE
|
||||
// WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, current_holders.posMasterNo)
|
||||
// WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, current_holders.posMasterNo)
|
||||
// WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, current_holders.posMasterNo)
|
||||
|
|
@ -5562,84 +5562,84 @@ export class ProfileController extends Controller {
|
|||
// END LIKE :keyword
|
||||
// `;
|
||||
// }
|
||||
let nodeCondition = "1=1";
|
||||
let nodeAll = "";
|
||||
let orgRoot = null;
|
||||
let orgChild1 = null;
|
||||
let orgChild2 = null;
|
||||
let orgChild3 = null;
|
||||
let orgChild4 = null;
|
||||
|
||||
let pmsCondition = "1=1";
|
||||
let orgRootPms = null;
|
||||
let orgChild1Pms = null;
|
||||
let orgChild2Pms = null;
|
||||
let orgChild3Pms = null;
|
||||
let orgChild4Pms = null;
|
||||
let nodeCondition = "1=1";
|
||||
let nodeAll = "";
|
||||
let orgRoot = null;
|
||||
let orgChild1 = null;
|
||||
let orgChild2 = null;
|
||||
let orgChild3 = null;
|
||||
let orgChild4 = null;
|
||||
|
||||
if (node === 0 && nodeId) {
|
||||
orgRoot = await this.orgRootRepo.findOne({where: { id: nodeId }});
|
||||
if (orgRoot) {
|
||||
let pmsCondition = "1=1";
|
||||
let orgRootPms = null;
|
||||
let orgChild1Pms = null;
|
||||
let orgChild2Pms = null;
|
||||
let orgChild3Pms = null;
|
||||
let orgChild4Pms = null;
|
||||
|
||||
if (node === 0 && nodeId) {
|
||||
orgRoot = await this.orgRootRepo.findOne({ where: { id: nodeId } });
|
||||
if (orgRoot) {
|
||||
nodeCondition = "profileSalary.orgRoot = :orgRoot";
|
||||
}
|
||||
if (isAll == false) nodeAll = " AND profileSalary.orgChild1 IS NULL";
|
||||
} else if (node === 1 && nodeId) {
|
||||
orgChild1 = await this.orgChild1Repo.findOne({where: { id: nodeId }});
|
||||
}
|
||||
if (isAll == false) nodeAll = " AND profileSalary.orgChild1 IS NULL";
|
||||
} else if (node === 1 && nodeId) {
|
||||
orgChild1 = await this.orgChild1Repo.findOne({ where: { id: nodeId } });
|
||||
if (orgChild1) {
|
||||
nodeCondition = "profileSalary.orgChild1 = :orgChild1";
|
||||
}
|
||||
if (isAll == false) nodeAll = " AND profileSalary.orgChild2 IS NULL";
|
||||
} else if (node === 2 && nodeId) {
|
||||
orgChild2 = await this.orgChild2Repo.findOne({where: { id: nodeId }});
|
||||
if (orgChild2) {
|
||||
nodeCondition = "profileSalary.orgChild2 = :orgChild2";
|
||||
}
|
||||
if (isAll == false) nodeAll = " AND profileSalary.orgChild3 IS NULL";
|
||||
} else if (node === 3 && nodeId) {
|
||||
orgChild3 = await this.orgChild3Repo.findOne({where: { id: nodeId }});
|
||||
if (orgChild3) {
|
||||
nodeCondition = "profileSalary.orgChild3 = :orgChild3";
|
||||
}
|
||||
if (isAll == false) nodeAll = " AND profileSalary.orgChild4 IS NULL";
|
||||
} else if (node === 4 && nodeId) {
|
||||
orgChild4 = await this.orgChild4Repo.findOne({where: { id: nodeId }});
|
||||
if (orgChild4) {
|
||||
nodeCondition = "profileSalary.orgChild4 = :orgChild4";
|
||||
}
|
||||
}
|
||||
nodeCondition = nodeCondition + nodeAll;
|
||||
|
||||
if (_data.root) {
|
||||
orgRootPms = await this.orgRootRepo.findOne({where: { id: _data.root }});
|
||||
if (orgRootPms) {
|
||||
pmsCondition = "profileSalary.orgRoot = :orgRoot";
|
||||
}
|
||||
if (isAll == false) nodeAll = " AND profileSalary.orgChild1 IS NULL";
|
||||
} else if (_data.child1) {
|
||||
orgChild1Pms = await this.orgChild1Repo.findOne({where: { id: _data.child1 }});
|
||||
if (orgChild1Pms) {
|
||||
pmsCondition = "profileSalary.orgChild1 = :orgChild1";
|
||||
nodeCondition = "profileSalary.orgChild1 = :orgChild1";
|
||||
}
|
||||
if (isAll == false) nodeAll = " AND profileSalary.orgChild2 IS NULL";
|
||||
} else if (_data.child2) {
|
||||
orgChild2Pms = await this.orgChild2Repo.findOne({where: { id: _data.child2 }});
|
||||
if (orgChild2Pms) {
|
||||
pmsCondition = "profileSalary.orgChild2 = :orgChild2";
|
||||
} else if (node === 2 && nodeId) {
|
||||
orgChild2 = await this.orgChild2Repo.findOne({ where: { id: nodeId } });
|
||||
if (orgChild2) {
|
||||
nodeCondition = "profileSalary.orgChild2 = :orgChild2";
|
||||
}
|
||||
if (isAll == false) nodeAll = " AND profileSalary.orgChild3 IS NULL";
|
||||
} else if (_data.child3) {
|
||||
orgChild3Pms = await this.orgChild3Repo.findOne({where: { id: _data.child3 }});
|
||||
if (orgChild3Pms) {
|
||||
pmsCondition = "profileSalary.orgChild3 = :orgChild3";
|
||||
} else if (node === 3 && nodeId) {
|
||||
orgChild3 = await this.orgChild3Repo.findOne({ where: { id: nodeId } });
|
||||
if (orgChild3) {
|
||||
nodeCondition = "profileSalary.orgChild3 = :orgChild3";
|
||||
}
|
||||
if (isAll == false) nodeAll = " AND profileSalary.orgChild4 IS NULL";
|
||||
} else if (_data.child4) {
|
||||
orgChild4Pms = await this.orgChild4Repo.findOne({where: { id: _data.child4 }});
|
||||
if (orgChild4Pms) {
|
||||
pmsCondition = "profileSalary.orgChild4 = :orgChild4";
|
||||
} else if (node === 4 && nodeId) {
|
||||
orgChild4 = await this.orgChild4Repo.findOne({ where: { id: nodeId } });
|
||||
if (orgChild4) {
|
||||
nodeCondition = "profileSalary.orgChild4 = :orgChild4";
|
||||
}
|
||||
}
|
||||
pmsCondition = pmsCondition + nodeAll;
|
||||
}
|
||||
nodeCondition = nodeCondition + nodeAll;
|
||||
|
||||
if (_data.root) {
|
||||
orgRootPms = await this.orgRootRepo.findOne({ where: { id: _data.root } });
|
||||
if (orgRootPms) {
|
||||
pmsCondition = "profileSalary.orgRoot = :orgRootPms";
|
||||
}
|
||||
if (isAll == false) nodeAll = " AND profileSalary.orgChild1 IS NULL";
|
||||
} else if (_data.child1) {
|
||||
orgChild1Pms = await this.orgChild1Repo.findOne({ where: { id: _data.child1 } });
|
||||
if (orgChild1Pms) {
|
||||
pmsCondition = "profileSalary.orgChild1 = :orgChild1Pms";
|
||||
}
|
||||
if (isAll == false) nodeAll = " AND profileSalary.orgChild2 IS NULL";
|
||||
} else if (_data.child2) {
|
||||
orgChild2Pms = await this.orgChild2Repo.findOne({ where: { id: _data.child2 } });
|
||||
if (orgChild2Pms) {
|
||||
pmsCondition = "profileSalary.orgChild2 = :orgChild2Pms";
|
||||
}
|
||||
if (isAll == false) nodeAll = " AND profileSalary.orgChild3 IS NULL";
|
||||
} else if (_data.child3) {
|
||||
orgChild3Pms = await this.orgChild3Repo.findOne({ where: { id: _data.child3 } });
|
||||
if (orgChild3Pms) {
|
||||
pmsCondition = "profileSalary.orgChild3 = :orgChild3Pms";
|
||||
}
|
||||
if (isAll == false) nodeAll = " AND profileSalary.orgChild4 IS NULL";
|
||||
} else if (_data.child4) {
|
||||
orgChild4Pms = await this.orgChild4Repo.findOne({ where: { id: _data.child4 } });
|
||||
if (orgChild4Pms) {
|
||||
pmsCondition = "profileSalary.orgChild4 = :orgChild4Pms";
|
||||
}
|
||||
}
|
||||
pmsCondition = pmsCondition + nodeAll;
|
||||
|
||||
// const findRevision = await this.orgRevisionRepo.findOne({
|
||||
// where: { orgRevisionIsCurrent: true },
|
||||
|
|
@ -5647,22 +5647,27 @@ export class ProfileController extends Controller {
|
|||
// if (!findRevision) {
|
||||
// throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
// }
|
||||
const [record, total] = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.leftJoinAndSelect("profile.profileSalary", "profileSalary")
|
||||
const [record, total] = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.leftJoinAndSelect("profile.profileSalary", "profileSalary")
|
||||
// .leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||
// .leftJoinAndSelect("current_holders.positions", "positions")
|
||||
// .leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||
.where(
|
||||
new Brackets((qb) => {
|
||||
qb.where("profile.isLeave = :isLeave", { isLeave: true })
|
||||
.orWhere("profile.isRetirement = :isRetirement", { isRetirement: true });
|
||||
})
|
||||
)
|
||||
.andWhere("profileSalary.order = (SELECT MAX(ps.order) FROM profileSalary ps WHERE ps.profileId = profile.id)")
|
||||
|
||||
.where(
|
||||
new Brackets((qb) => {
|
||||
qb.where("profile.isLeave = :isLeave", { isLeave: true }).orWhere(
|
||||
"profile.isRetirement = :isRetirement",
|
||||
{ isRetirement: true },
|
||||
);
|
||||
}),
|
||||
)
|
||||
.andWhere("profile.leaveCommandId Is NOT NULL")
|
||||
.andWhere(
|
||||
"profileSalary.order = (SELECT MAX(ps.order) FROM profileSalary ps WHERE ps.profileId = profile.id)",
|
||||
)
|
||||
|
||||
.andWhere(
|
||||
posType != undefined && posType != null && posType != ""
|
||||
? "posType.posTypeName LIKE :keyword1"
|
||||
|
|
@ -5685,18 +5690,18 @@ export class ProfileController extends Controller {
|
|||
: "1=1",
|
||||
)
|
||||
.andWhere(pmsCondition, {
|
||||
orgRoot: orgRootPms ? orgRootPms.orgRootName : undefined,
|
||||
orgChild1: orgChild1Pms ? orgChild1Pms.orgChild1Name : undefined,
|
||||
orgChild2: orgChild2Pms ? orgChild2Pms.orgChild2Name : undefined,
|
||||
orgChild3: orgChild3Pms ? orgChild3Pms.orgChild3Name : undefined,
|
||||
orgChild4: orgChild4Pms ? orgChild4Pms.orgChild4Name : undefined,
|
||||
orgRootPms: orgRootPms ? orgRootPms.orgRootName : "",
|
||||
orgChild1Pms: orgChild1Pms ? orgChild1Pms.orgChild1Name : "",
|
||||
orgChild2Pms: orgChild2Pms ? orgChild2Pms.orgChild2Name : "",
|
||||
orgChild3Pms: orgChild3Pms ? orgChild3Pms.orgChild3Name : "",
|
||||
orgChild4Pms: orgChild4Pms ? orgChild4Pms.orgChild4Name : "",
|
||||
})
|
||||
.andWhere(nodeCondition, {
|
||||
orgRoot: orgRoot ? orgRoot.orgRootName : undefined,
|
||||
orgChild1: orgChild1 ? orgChild1.orgChild1Name : undefined,
|
||||
orgChild2: orgChild2 ? orgChild2.orgChild2Name : undefined,
|
||||
orgChild3: orgChild3 ? orgChild3.orgChild3Name : undefined,
|
||||
orgChild4: orgChild4 ? orgChild4.orgChild4Name : undefined,
|
||||
orgRoot: orgRoot ? orgRoot.orgRootName : "",
|
||||
orgChild1: orgChild1 ? orgChild1.orgChild1Name : "",
|
||||
orgChild2: orgChild2 ? orgChild2.orgChild2Name : "",
|
||||
orgChild3: orgChild3 ? orgChild3.orgChild3Name : "",
|
||||
orgChild4: orgChild4 ? orgChild4.orgChild4Name : "",
|
||||
})
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
|
|
@ -5711,13 +5716,13 @@ export class ProfileController extends Controller {
|
|||
}),
|
||||
)
|
||||
// .orderBy("current_holders.posMasterNo", "ASC")
|
||||
// .orderBy(`${sortBy}`, sort)
|
||||
// .orderBy(`${sortBy}`, sort)
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
// const posExecutive =
|
||||
// _data.current_holders.length == 0 ||
|
||||
// _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null ||
|
||||
|
|
@ -5734,7 +5739,7 @@ export class ProfileController extends Controller {
|
|||
// .find((x) => x.orgRevisionId == findRevision.id)
|
||||
// ?.positions.find((x: any) => x.positionIsSelected == true)?.posExecutive
|
||||
// ?.posExecutiveName;
|
||||
|
||||
|
||||
// const shortName =
|
||||
// _data.current_holders.length == 0
|
||||
// ? null
|
||||
|
|
@ -5766,73 +5771,91 @@ export class ProfileController extends Controller {
|
|||
// _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||
// ? null
|
||||
// : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||
|
||||
|
||||
// const child1 =
|
||||
// _data.current_holders == null ||
|
||||
// _data.current_holders.length == 0 ||
|
||||
// _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||
// ? null
|
||||
// : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1;
|
||||
|
||||
|
||||
// const child2 =
|
||||
// _data.current_holders == null ||
|
||||
// _data.current_holders.length == 0 ||
|
||||
// _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||
// ? null
|
||||
// : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2;
|
||||
|
||||
|
||||
// const child3 =
|
||||
// _data.current_holders == null ||
|
||||
// _data.current_holders.length == 0 ||
|
||||
// _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||
// ? null
|
||||
// : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3;
|
||||
|
||||
|
||||
// const child4 =
|
||||
// _data.current_holders == null ||
|
||||
// _data.current_holders.length == 0 ||
|
||||
// _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||
// ? null
|
||||
// : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4;
|
||||
|
||||
|
||||
// let _child1 = child1?.orgChild1Name;
|
||||
// let _child2 = child2?.orgChild2Name;
|
||||
// let _child3 = child3?.orgChild3Name;
|
||||
// let _child4 = child4?.orgChild4Name;
|
||||
|
||||
return {
|
||||
id: _data.id,
|
||||
avatar: _data.avatar,
|
||||
avatarName: _data.avatarName,
|
||||
dateAppoint: _data.dateAppoint,
|
||||
prefix: _data.prefix,
|
||||
rank: _data.rank,
|
||||
firstName: _data.firstName,
|
||||
lastName: _data.lastName,
|
||||
citizenId: _data.citizenId,
|
||||
|
||||
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
||||
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
||||
posLevelId: _data.posLevel == null ? null : _data.posLevel.id,
|
||||
posTypeId: _data.posType == null ? null : _data.posType.id,
|
||||
position: _data.position,
|
||||
posExecutive: _data.profileSalary[0].positionExecutive == null ? null : _data.profileSalary[0].positionExecutive,
|
||||
posNo: _data.profileSalary[0].posNoAbb == "" ? "" : _data.profileSalary[0].posNoAbb + _data.profileSalary[0].posNo == "" ? "" : _data.profileSalary[0].posNo,
|
||||
rootId: null ,
|
||||
root: _data.profileSalary[0].orgRoot == null ? null : _data.profileSalary[0].orgRoot,
|
||||
orgRootShortName: _data.profileSalary[0].posNoAbb == null ? null : _data.profileSalary[0].posNoAbb,
|
||||
orgRevisionId: null,
|
||||
org: (_data.profileSalary[0].orgChild4 == null ? "" : _data.profileSalary[0].orgChild4 + "\n") +
|
||||
(_data.profileSalary[0].orgChild3 == null ? "" : _data.profileSalary[0].orgChild3 + "\n") +
|
||||
(_data.profileSalary[0].orgChild2 == null ? "" : _data.profileSalary[0].orgChild2 + "\n") +
|
||||
(_data.profileSalary[0].orgChild1 == null ? "" : _data.profileSalary[0].orgChild1 + "\n") +
|
||||
(_data.profileSalary[0].orgRoot == null ? "" : _data.profileSalary[0].orgRoot) ,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
return new HttpSuccess({ data: data, total });
|
||||
}
|
||||
return {
|
||||
id: _data.id,
|
||||
avatar: _data.avatar,
|
||||
avatarName: _data.avatarName,
|
||||
dateAppoint: _data.dateAppoint,
|
||||
prefix: _data.prefix,
|
||||
rank: _data.rank,
|
||||
firstName: _data.firstName,
|
||||
lastName: _data.lastName,
|
||||
citizenId: _data.citizenId,
|
||||
|
||||
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
||||
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
||||
posLevelId: _data.posLevel == null ? null : _data.posLevel.id,
|
||||
posTypeId: _data.posType == null ? null : _data.posType.id,
|
||||
position: _data.position,
|
||||
posExecutive:
|
||||
_data.profileSalary[0].positionExecutive == null
|
||||
? null
|
||||
: _data.profileSalary[0].positionExecutive,
|
||||
posNo:
|
||||
_data.profileSalary[0].posNoAbb == ""
|
||||
? ""
|
||||
: _data.profileSalary[0].posNoAbb + _data.profileSalary[0].posNo == ""
|
||||
? ""
|
||||
: _data.profileSalary[0].posNo,
|
||||
rootId: null,
|
||||
root: _data.profileSalary[0].orgRoot == null ? null : _data.profileSalary[0].orgRoot,
|
||||
orgRootShortName:
|
||||
_data.profileSalary[0].posNoAbb == null ? null : _data.profileSalary[0].posNoAbb,
|
||||
orgRevisionId: null,
|
||||
org:
|
||||
(_data.profileSalary[0].orgChild4 == null
|
||||
? ""
|
||||
: _data.profileSalary[0].orgChild4 + "\n") +
|
||||
(_data.profileSalary[0].orgChild3 == null
|
||||
? ""
|
||||
: _data.profileSalary[0].orgChild3 + "\n") +
|
||||
(_data.profileSalary[0].orgChild2 == null
|
||||
? ""
|
||||
: _data.profileSalary[0].orgChild2 + "\n") +
|
||||
(_data.profileSalary[0].orgChild1 == null
|
||||
? ""
|
||||
: _data.profileSalary[0].orgChild1 + "\n") +
|
||||
(_data.profileSalary[0].orgRoot == null ? "" : _data.profileSalary[0].orgRoot),
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
return new HttpSuccess({ data: data, total });
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายละเอียดรายการทะเบียนประวัติ
|
||||
|
|
@ -6256,7 +6279,6 @@ export class ProfileController extends Controller {
|
|||
return new HttpSuccess({ data: data, total });
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* API ค้นหารายชื่อไปครองตำแหน่ง
|
||||
*
|
||||
|
|
@ -6539,48 +6561,45 @@ export class ProfileController extends Controller {
|
|||
}
|
||||
|
||||
/**
|
||||
* API ข้อมูลสิทธิ์การแก้ไขทะเบียนประวัติ
|
||||
*
|
||||
* @summary ORG_065 - ข้อมูลสิทธิ์การแก้ไขทะเบียนประวัติ
|
||||
*
|
||||
*/
|
||||
@Get("keycloak/permissionProfile")
|
||||
async getPermissionProfile(
|
||||
@Request() request: { user: Record<string, any> }
|
||||
) {
|
||||
let orgRevisionPublish: any = await this.orgRevisionRepo
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.orgRevisionIsDraft = false")
|
||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||
.getOne();
|
||||
if (!orgRevisionPublish) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง");
|
||||
}
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: {keycloak: request.user.sub },
|
||||
});
|
||||
if(!profile){
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้");
|
||||
}
|
||||
const permissionProflile = await this.permissionProflileRepository.findOne({
|
||||
relations : ["orgRootTree"],
|
||||
where:{
|
||||
profileId: profile.id,
|
||||
orgRootTree:{
|
||||
orgRevisionId: orgRevisionPublish.id
|
||||
}
|
||||
* API ข้อมูลสิทธิ์การแก้ไขทะเบียนประวัติ
|
||||
*
|
||||
* @summary ORG_065 - ข้อมูลสิทธิ์การแก้ไขทะเบียนประวัติ
|
||||
*
|
||||
*/
|
||||
@Get("keycloak/permissionProfile")
|
||||
async getPermissionProfile(@Request() request: { user: Record<string, any> }) {
|
||||
let orgRevisionPublish: any = await this.orgRevisionRepo
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.orgRevisionIsDraft = false")
|
||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||
.getOne();
|
||||
if (!orgRevisionPublish) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง");
|
||||
}
|
||||
});
|
||||
|
||||
const _profile: any = {
|
||||
profileId: profile?.id??null,
|
||||
isEdit: permissionProflile?.isEdit??false,
|
||||
isCheck: permissionProflile?.isCheck??false,
|
||||
};
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { keycloak: request.user.sub },
|
||||
});
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้");
|
||||
}
|
||||
const permissionProflile = await this.permissionProflileRepository.findOne({
|
||||
relations: ["orgRootTree"],
|
||||
where: {
|
||||
profileId: profile.id,
|
||||
orgRootTree: {
|
||||
orgRevisionId: orgRevisionPublish.id,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
return new HttpSuccess(_profile);
|
||||
}
|
||||
const _profile: any = {
|
||||
profileId: profile?.id ?? null,
|
||||
isEdit: permissionProflile?.isEdit ?? false,
|
||||
isCheck: permissionProflile?.isCheck ?? false,
|
||||
};
|
||||
|
||||
return new HttpSuccess(_profile);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ข้อมูลทะเบียนประวัติตาม keycloak
|
||||
|
|
@ -7668,16 +7687,16 @@ export class ProfileController extends Controller {
|
|||
};
|
||||
}),
|
||||
);
|
||||
const permissionProflile = await this.permissionProflileRepository.findOne({
|
||||
relations : ["orgRootTree"],
|
||||
where:{
|
||||
profileId: id,
|
||||
orgRootTree:{
|
||||
orgRevisionId: orgRevisionPublish.id
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const permissionProflile = await this.permissionProflileRepository.findOne({
|
||||
relations: ["orgRootTree"],
|
||||
where: {
|
||||
profileId: id,
|
||||
orgRootTree: {
|
||||
orgRevisionId: orgRevisionPublish.id,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const _profile: any = {
|
||||
profileId: profile.id,
|
||||
prefix: profile.prefix,
|
||||
|
|
@ -7732,8 +7751,8 @@ export class ProfileController extends Controller {
|
|||
? `${profile.profileEducations[0].degree ?? ""} ${profile.profileEducations[0].field ?? ""}`
|
||||
: "-",
|
||||
statusCheckEdit: profile.statusCheckEdit,
|
||||
isEdit: permissionProflile?.isEdit??false,
|
||||
isCheck: permissionProflile?.isCheck??false,
|
||||
isEdit: permissionProflile?.isEdit ?? false,
|
||||
isCheck: permissionProflile?.isCheck ?? false,
|
||||
};
|
||||
|
||||
if (_profile.child4Id != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue