Merge branch 'development' into 'devops-staging'
Development See merge request empatnusabangsa/ppob/ppob-backend!28
This commit is contained in:
commit
f63dad68ed
|
@ -149,14 +149,10 @@ export class UsersController {
|
|||
|
||||
@Get('find-by-supperior')
|
||||
async findBySuperrior(@Request() req, @Query('page') page: number) {
|
||||
const [data, count] = await this.usersService.findBySuperrior(
|
||||
req.user.userId,
|
||||
page,
|
||||
);
|
||||
const data = await this.usersService.findBySuperrior(req.user.userId, page);
|
||||
|
||||
return {
|
||||
data,
|
||||
count,
|
||||
...data,
|
||||
statusCode: HttpStatus.OK,
|
||||
message: 'success',
|
||||
};
|
||||
|
|
|
@ -160,18 +160,39 @@ export class UsersService {
|
|||
});
|
||||
}
|
||||
|
||||
findBySuperrior(superriorId: string, page: number) {
|
||||
return this.usersRepository.findAndCount({
|
||||
skip: page * 10,
|
||||
take: 10,
|
||||
relations: ['roles'],
|
||||
where: {
|
||||
async findBySuperrior(superriorId: string, page: number) {
|
||||
const baseQuery = this.usersRepository
|
||||
.createQueryBuilder('user')
|
||||
.where('user.id != :id and user.superior_id = :superior', {
|
||||
id: superriorId,
|
||||
superior: superriorId,
|
||||
},
|
||||
order: {
|
||||
updatedAt: 'DESC',
|
||||
},
|
||||
});
|
||||
})
|
||||
.leftJoinAndSelect('user.roles', 'roles', `roles.id = user.roles_id`)
|
||||
.leftJoinAndMapOne(
|
||||
'user.user_detail',
|
||||
UserDetail,
|
||||
'user_detail',
|
||||
`user_detail.user = user.id`,
|
||||
)
|
||||
.select([
|
||||
'user.id',
|
||||
'user.username',
|
||||
'user.isActive',
|
||||
'roles.name',
|
||||
'user_detail',
|
||||
]);
|
||||
|
||||
const data = await baseQuery
|
||||
.skip(page * 10)
|
||||
.take(10)
|
||||
.getMany();
|
||||
|
||||
const totalData = await baseQuery.getCount();
|
||||
|
||||
return {
|
||||
data,
|
||||
count: totalData,
|
||||
};
|
||||
}
|
||||
|
||||
async findExist(id: string) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user