เพิ่มผู้บังคับบัญชา
This commit is contained in:
parent
474630a7ba
commit
ad08061836
5 changed files with 110 additions and 0 deletions
|
|
@ -44,6 +44,65 @@ export class ProfileController extends Controller {
|
|||
private posLevelRepo = AppDataSource.getRepository(PosLevel);
|
||||
private posTypeRepo = AppDataSource.getRepository(PosType);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param {string} id Id ทะเบียนประวัติ
|
||||
*/
|
||||
@Get("placement/{id}")
|
||||
async getProfilePlacement(@Path() id: string) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { id },
|
||||
});
|
||||
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const _caregiver = await this.profileRepo.find({
|
||||
relations: { posLevel: true, posType: true },
|
||||
});
|
||||
const _commander = await this.profileRepo.find({
|
||||
relations: { posLevel: true, posType: true },
|
||||
});
|
||||
const _chairman = await this.profileRepo.find({
|
||||
relations: { posLevel: true, posType: true },
|
||||
});
|
||||
|
||||
const caregiver = _caregiver.map((_data) => ({
|
||||
id: _data.id,
|
||||
prefix: _data.prefix,
|
||||
firstName: _data.firstName,
|
||||
lastName: _data.lastName,
|
||||
citizenId: _data.citizenId,
|
||||
position: _data.position,
|
||||
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
||||
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
||||
isDirector: true,
|
||||
}));
|
||||
const commander = _commander.map((_data) => ({
|
||||
id: _data.id,
|
||||
prefix: _data.prefix,
|
||||
firstName: _data.firstName,
|
||||
lastName: _data.lastName,
|
||||
citizenId: _data.citizenId,
|
||||
position: _data.position,
|
||||
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
||||
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
||||
isDirector: true,
|
||||
}));
|
||||
const chairman = _chairman.map((_data) => ({
|
||||
id: _data.id,
|
||||
prefix: _data.prefix,
|
||||
firstName: _data.firstName,
|
||||
lastName: _data.lastName,
|
||||
citizenId: _data.citizenId,
|
||||
position: _data.position,
|
||||
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
||||
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
||||
isDirector: true,
|
||||
}));
|
||||
return new HttpSuccess({ caregiver, commander, chairman });
|
||||
}
|
||||
|
||||
/**
|
||||
* API สร้างทะเบียนประวัติ
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue