ผู้บังคับปัญชา
This commit is contained in:
parent
19e1b55aee
commit
2b72ad39c9
1 changed files with 57 additions and 0 deletions
|
|
@ -103,6 +103,63 @@ export class ProfileController extends Controller {
|
|||
}));
|
||||
return new HttpSuccess({ caregiver, commander, chairman });
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Get("commander")
|
||||
async getProfileCommander(@Request() request: RequestWithUser) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { keycloak: request.user.sub },
|
||||
});
|
||||
|
||||
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