add commander name
This commit is contained in:
parent
97eae36fff
commit
87ca9aa73a
1 changed files with 234 additions and 0 deletions
|
|
@ -25,6 +25,7 @@ import { ProfileEmployee } from "../entities/ProfileEmployee";
|
|||
import { Position } from "../entities/Position";
|
||||
import { Insignia } from "../entities/Insignia";
|
||||
import { CreateProfileInsignia, ProfileInsignia } from "../entities/ProfileInsignia";
|
||||
import { PosMaster } from "../entities/PosMaster";
|
||||
|
||||
@Route("api/v1/org/dotnet")
|
||||
@Tags("Dotnet")
|
||||
|
|
@ -40,6 +41,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
private profileRepo = AppDataSource.getRepository(Profile);
|
||||
private profileEmpRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||
private positionRepository = AppDataSource.getRepository(Position);
|
||||
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
||||
private insigniaRepo = AppDataSource.getRepository(ProfileInsignia);
|
||||
|
||||
/**
|
||||
|
|
@ -292,6 +294,138 @@ export class OrganizationDotnetController extends Controller {
|
|||
},
|
||||
},
|
||||
});
|
||||
|
||||
const org = {
|
||||
root:
|
||||
profile?.current_holders?.find(
|
||||
(x) =>
|
||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||
)?.orgRoot?.id ?? null,
|
||||
child1:
|
||||
profile?.current_holders?.find(
|
||||
(x) =>
|
||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||
)?.orgChild1?.id ?? null,
|
||||
child2:
|
||||
profile?.current_holders?.find(
|
||||
(x) =>
|
||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||
)?.orgChild2?.id ?? null,
|
||||
child3:
|
||||
profile?.current_holders?.find(
|
||||
(x) =>
|
||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||
)?.orgChild3?.id ?? null,
|
||||
child4:
|
||||
profile?.current_holders?.find(
|
||||
(x) =>
|
||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||
)?.orgChild4?.id ?? null,
|
||||
};
|
||||
|
||||
let fullname = "";
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
relations: ['current_holder'],
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
isDirector: true,
|
||||
orgRootId: org?.root ?? "",
|
||||
orgChild1Id: org?.child1 ?? "",
|
||||
orgChild2Id: org?.child2 ?? "",
|
||||
orgChild3Id: org?.child3 ?? "",
|
||||
orgChild4Id: org?.child4 ?? "",
|
||||
},
|
||||
});
|
||||
|
||||
if (pos) {
|
||||
fullname = pos.current_holder.prefix + pos.current_holder.firstName + " " + pos.current_holder.lastName;
|
||||
} else {
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
relations: ['current_holder'],
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
isDirector: true,
|
||||
orgRootId: org?.root ?? "",
|
||||
orgChild1Id: org?.child1 ?? "",
|
||||
orgChild2Id: org?.child2 ?? "",
|
||||
orgChild3Id: org?.child3 ?? "",
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
});
|
||||
if (pos) {
|
||||
fullname = pos.current_holder.prefix + pos.current_holder.firstName + " " + pos.current_holder.lastName;
|
||||
} else {
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
relations: ['current_holder'],
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
isDirector: true,
|
||||
orgRootId: org?.root ?? "",
|
||||
orgChild1Id: org?.child1 ?? "",
|
||||
orgChild2Id: org?.child2 ?? "",
|
||||
orgChild3Id: IsNull(),
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
});
|
||||
if (pos) {
|
||||
fullname = pos.current_holder.prefix + pos.current_holder.firstName + " " + pos.current_holder.lastName;
|
||||
} else {
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
relations: ['current_holder'],
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
isDirector: true,
|
||||
orgRootId: org?.root ?? "",
|
||||
orgChild1Id: org?.child1 ?? "",
|
||||
orgChild2Id: IsNull(),
|
||||
orgChild3Id: IsNull(),
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
});
|
||||
if (pos) {
|
||||
fullname = pos.current_holder.prefix + pos.current_holder.firstName + " " + pos.current_holder.lastName;
|
||||
} else {
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
relations: ['current_holder'],
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
orgRootId: org?.root ?? "",
|
||||
orgChild1Id: IsNull(),
|
||||
orgChild2Id: IsNull(),
|
||||
orgChild3Id: IsNull(),
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
});
|
||||
if (pos) {
|
||||
fullname = pos.current_holder.prefix + pos.current_holder.firstName + " " + pos.current_holder.lastName;
|
||||
} else {
|
||||
fullname = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!profile) {
|
||||
const profile = await this.profileEmpRepo.findOne({
|
||||
relations: [
|
||||
|
|
@ -319,6 +453,104 @@ export class OrganizationDotnetController extends Controller {
|
|||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
let fullname = "";
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
relations: ['current_holder'],
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
isDirector: true,
|
||||
orgRootId: org?.root ?? "",
|
||||
orgChild1Id: org?.child1 ?? "",
|
||||
orgChild2Id: org?.child2 ?? "",
|
||||
orgChild3Id: org?.child3 ?? "",
|
||||
orgChild4Id: org?.child4 ?? "",
|
||||
},
|
||||
});
|
||||
|
||||
if (pos) {
|
||||
fullname = pos.current_holder.prefix + pos.current_holder.firstName + " " + pos.current_holder.lastName;
|
||||
} else {
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
relations: ['current_holder'],
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
isDirector: true,
|
||||
orgRootId: org?.root ?? "",
|
||||
orgChild1Id: org?.child1 ?? "",
|
||||
orgChild2Id: org?.child2 ?? "",
|
||||
orgChild3Id: org?.child3 ?? "",
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
});
|
||||
if (pos) {
|
||||
fullname = pos.current_holder.prefix + pos.current_holder.firstName + " " + pos.current_holder.lastName;
|
||||
} else {
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
relations: ['current_holder'],
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
isDirector: true,
|
||||
orgRootId: org?.root ?? "",
|
||||
orgChild1Id: org?.child1 ?? "",
|
||||
orgChild2Id: org?.child2 ?? "",
|
||||
orgChild3Id: IsNull(),
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
});
|
||||
if (pos) {
|
||||
fullname = pos.current_holder.prefix + pos.current_holder.firstName + " " + pos.current_holder.lastName;
|
||||
} else {
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
relations: ['current_holder'],
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
isDirector: true,
|
||||
orgRootId: org?.root ?? "",
|
||||
orgChild1Id: org?.child1 ?? "",
|
||||
orgChild2Id: IsNull(),
|
||||
orgChild3Id: IsNull(),
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
});
|
||||
if (pos) {
|
||||
fullname = pos.current_holder.prefix + pos.current_holder.firstName + " " + pos.current_holder.lastName;
|
||||
} else {
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
relations: ['current_holder'],
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
orgRootId: org?.root ?? "",
|
||||
orgChild1Id: IsNull(),
|
||||
orgChild2Id: IsNull(),
|
||||
orgChild3Id: IsNull(),
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
});
|
||||
if (pos) {
|
||||
fullname = pos.current_holder.prefix + pos.current_holder.firstName + " " + pos.current_holder.lastName;
|
||||
} else {
|
||||
fullname = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const mapProfile = {
|
||||
id: profile.id,
|
||||
avatar: profile.avatar,
|
||||
|
|
@ -391,6 +623,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||
)?.orgChild4?.orgChild4Name ?? null,
|
||||
commander: fullname,
|
||||
posLevel: profile.posLevel ? profile.posLevel : null,
|
||||
posType: profile.posType ? profile.posType : null,
|
||||
profileSalary: profile.profileSalary.length > 0 ? profile.profileSalary[0] : null,
|
||||
|
|
@ -472,6 +705,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||
)?.orgChild4?.orgChild4Name ?? null,
|
||||
commander: fullname,
|
||||
posLevel: profile.posLevel ? profile.posLevel : null,
|
||||
posType: profile.posType ? profile.posType : null,
|
||||
profileSalary: profile.profileSalary.length > 0 ? profile.profileSalary[0] : null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue