ปรับ api master/list

This commit is contained in:
Bright 2024-02-15 12:13:34 +07:00
parent d76af2c88c
commit a1610880f0

View file

@ -849,9 +849,21 @@ export class PositionController extends Controller {
},
relations: ["posLevel", "posType", "posExecutive"],
});
const profile = await this.profileRepository.findOne({
where: { id: String(posMaster.next_holderId) },
});
let profile: any;
const chkRevision = await this.orgRevisionRepository.findOne({
where: { id: posMaster.orgRevisionId }
})
if(chkRevision?.orgRevisionIsCurrent && !chkRevision?.orgRevisionIsDraft){
profile = await this.profileRepository.findOne({
where: { id: String(posMaster.current_holderId) },
});
}
else if(!chkRevision?.orgRevisionIsCurrent && chkRevision?.orgRevisionIsDraft){
profile = await this.profileRepository.findOne({
where: { id: String(posMaster.next_holderId) },
});
}
const type = await this.posTypeRepository.findOne({
where: { id: String(profile?.posTypeId) },
});
@ -925,10 +937,11 @@ export class PositionController extends Controller {
: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
orgShortname: shortName,
isSit: posMaster.isSit,
positionNextHolder:
profilePosition:
profile == null || profile.position == null ? null : profile.position,
postypeNextHolder: type == null || type.posTypeName == null ? null : type.posTypeName,
poslevelNextHolder:
profilePostype:
type == null || type.posTypeName == null ? null : type.posTypeName,
profilePoslevel:
level == null || level.posLevelName == null ? null : level.posLevelName,
positions: positions.map((position) => ({
id: position.id,