ผู้บังคับปัญชา

This commit is contained in:
Kittapath 2024-04-26 14:41:55 +07:00
parent 19e1b55aee
commit 2b72ad39c9

View file

@ -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