add fields api master/list

This commit is contained in:
Bright 2024-02-15 09:39:13 +07:00
parent 507b527c5e
commit edd5fdb3aa

View file

@ -33,6 +33,7 @@ import { OrgChild2 } from "../entities/OrgChild2";
import { OrgChild3 } from "../entities/OrgChild3";
import { OrgChild4 } from "../entities/OrgChild4";
import { Position } from "../entities/Position";
import { Profile } from "../entities/Profile";
@Route("api/v1/org/pos")
@Tags("Position")
// @Security("bearerAuth")
@ -48,7 +49,7 @@ export class PositionController extends Controller {
private posDictRepository = AppDataSource.getRepository(PosDict);
private posMasterRepository = AppDataSource.getRepository(PosMaster);
private positionRepository = AppDataSource.getRepository(Position);
private profileRepository = AppDataSource.getRepository(Profile);
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
private child1Repository = AppDataSource.getRepository(OrgChild1);
@ -887,6 +888,15 @@ export class PositionController extends Controller {
},
relations: ["posLevel", "posType", "posExecutive"],
});
const profile = await this.profileRepository.findOne({
where: { id: String(posMaster.next_holderId) }
})
const type = await this.posTypeRepository.findOne({
where: { id: String(profile?.posTypeId) }
})
const level = await this.posLevelRepository.findOne({
where: { id: String(profile?.posLevelId)}
})
let shortName = "";
@ -953,6 +963,10 @@ export class PositionController extends Controller {
? null
: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
orgShortname: shortName,
isSit: posMaster.isSit,
positionNextHolder: profile == null || profile.position == null? null : profile.position,
postypeNextHolder: type == null || type.posTypeName == null ? null : type.posTypeName,
poslevelNextHolder: level == null || level.posLevelName == null ? null : level.posLevelName,
positions: positions.map((position) => ({
id: position.id,
positionName: position.positionName,