Merge branch 'development' into 'devops-staging'

Development

See merge request empatnusabangsa/ppob/ppob-backend!73
This commit is contained in:
ilham dwi pratama 2021-12-29 08:13:57 +00:00
commit 325acb85a5
3 changed files with 29 additions and 5 deletions

View File

@ -336,8 +336,8 @@ export class ProductService {
} }
const data = await baseQuery const data = await baseQuery
.offset(page * 10) .offset(page * pageSize)
.limit(10) .limit(pageSize)
.getRawMany(); .getRawMany();
const totalData = await baseQuery.getCount(); const totalData = await baseQuery.getCount();

View File

@ -113,8 +113,18 @@ export class UsersController {
} }
@Get() @Get()
async findAll(@Request() req, @Query('page') page: number) { async findAll(
const data = await this.usersService.findAll(page, req.user.userId); @Request() req,
@Query('page') page: number,
@Query('superior') superior: string,
@Query('type') type: string,
) {
const data = await this.usersService.findAll(
page,
req.user.userId,
superior == 'null' ? null : superior,
type == 'null' ? null : type,
);
return { return {
...data, ...data,

View File

@ -118,7 +118,7 @@ export class UsersService {
return userData; return userData;
} }
async findAll(page: number, id: string) { async findAll(page: number, id: string, superior: string, type: string) {
const baseQuery = this.usersRepository const baseQuery = this.usersRepository
.createQueryBuilder('user') .createQueryBuilder('user')
.where('user.id != :id', { .where('user.id != :id', {
@ -148,6 +148,20 @@ export class UsersService {
'coa.amount', '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 const data = await baseQuery
.orderBy('user.createdAt', 'DESC') .orderBy('user.createdAt', 'DESC')
.skip(page * 10) .skip(page * 10)