orgLevel and orgShortname
This commit is contained in:
parent
44be85a749
commit
acc9075f97
1 changed files with 69 additions and 0 deletions
|
|
@ -1431,11 +1431,77 @@ export class PositionController extends Controller {
|
|||
@Get("position/{id}")
|
||||
async detailPosition(@Path() id: string) {
|
||||
const posMaster = await this.posMasterRepository.findOne({
|
||||
relations: [
|
||||
"orgRoot",
|
||||
"orgChild1",
|
||||
"orgChild2",
|
||||
"orgChild3",
|
||||
"orgChild4",
|
||||
],
|
||||
where: { id },
|
||||
});
|
||||
if (!posMaster) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
let orgLevel: any;
|
||||
|
||||
switch (true) {
|
||||
case !!posMaster.orgChild4Id:
|
||||
orgLevel = 4;
|
||||
break;
|
||||
case !!posMaster.orgChild3Id:
|
||||
orgLevel = 3;
|
||||
break;
|
||||
case !!posMaster.orgChild2Id:
|
||||
orgLevel = 2;
|
||||
break;
|
||||
case !!posMaster.orgChild1Id:
|
||||
orgLevel = 1;
|
||||
break;
|
||||
case !!posMaster.orgRootId:
|
||||
orgLevel = 0;
|
||||
break;
|
||||
default:
|
||||
orgLevel = null; // ถ้าไม่มีข้อมูลเลย
|
||||
break;
|
||||
}
|
||||
let shortName = "";
|
||||
if (
|
||||
posMaster.orgRootId !== null &&
|
||||
posMaster.orgChild1Id == null &&
|
||||
posMaster.orgChild2Id == null &&
|
||||
posMaster.orgChild3Id == null
|
||||
) {
|
||||
shortName = posMaster.orgRoot.orgRootShortName;
|
||||
} else if (
|
||||
posMaster.orgRootId !== null &&
|
||||
posMaster.orgChild1Id !== null &&
|
||||
posMaster.orgChild2Id == null &&
|
||||
posMaster.orgChild3Id == null
|
||||
) {
|
||||
shortName = posMaster.orgChild1.orgChild1ShortName;
|
||||
} else if (
|
||||
posMaster.orgRootId !== null &&
|
||||
posMaster.orgChild1Id !== null &&
|
||||
posMaster.orgChild2Id !== null &&
|
||||
posMaster.orgChild3Id == null
|
||||
) {
|
||||
shortName = posMaster.orgChild2.orgChild2ShortName;
|
||||
} else if (
|
||||
posMaster.orgRootId !== null &&
|
||||
posMaster.orgChild1Id !== null &&
|
||||
posMaster.orgChild2Id !== null &&
|
||||
posMaster.orgChild3Id !== null
|
||||
) {
|
||||
shortName = posMaster.orgChild3.orgChild3ShortName;
|
||||
} else if (
|
||||
posMaster.orgRootId !== null &&
|
||||
posMaster.orgChild1Id !== null &&
|
||||
posMaster.orgChild2Id !== null &&
|
||||
posMaster.orgChild3Id !== null
|
||||
) {
|
||||
shortName = posMaster.orgChild4.orgChild4ShortName;
|
||||
}
|
||||
const positions = await this.positionRepository.find({
|
||||
where: { posMasterId: posMaster.id },
|
||||
relations: ["posType", "posLevel", "posExecutive"],
|
||||
|
|
@ -1457,6 +1523,8 @@ export class PositionController extends Controller {
|
|||
reason: posMaster.reason,
|
||||
// isOfficer: posMaster.isOfficer,
|
||||
isStaff: posMaster.isStaff,
|
||||
orgLevel: orgLevel,
|
||||
orgShortname: shortName,
|
||||
isDirector: posMaster.isDirector,
|
||||
positionSign: posMaster.positionSign,
|
||||
positions: positions.map((position) => ({
|
||||
|
|
@ -2594,6 +2662,7 @@ export class PositionController extends Controller {
|
|||
posMaster.ancestorDNA == null || posMaster.ancestorDNA == ""
|
||||
? "123"
|
||||
: posMaster.ancestorDNA,
|
||||
// current_holderId: Not(IsNull()),
|
||||
},
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
relations: [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue