add filter in user

This commit is contained in:
2021-12-29 07:59:07 +07:00
parent af8f42c2d3
commit e882237a8a
2 changed files with 27 additions and 3 deletions

View File

@@ -118,7 +118,7 @@ export class UsersService {
return userData;
}
async findAll(page: number, id: string) {
async findAll(page: number, id: string, superior: string, type: string) {
const baseQuery = this.usersRepository
.createQueryBuilder('user')
.where('user.id != :id', {
@@ -148,6 +148,20 @@ export class UsersService {
'coa.amount',
]);
if(superior){
baseQuery.where('user.superior = :id_supperior',{
id_supperior:superior
})
}
if(type){
if(type == 'partner'){
baseQuery.where('user.partner_id is not null')
} else {
baseQuery.where('user.partner_id is null')
}
}
const data = await baseQuery
.orderBy('user.createdAt', 'DESC')
.skip(page * 10)