add: paging in user and relation when get in user

This commit is contained in:
2021-12-08 10:46:39 +07:00
parent 96d5089dc8
commit a418e74db5
3 changed files with 39 additions and 6 deletions

View File

@@ -28,14 +28,25 @@ export class UsersService {
return this.usersRepository.findOneOrFail(result.identifiers[0].id);
}
findAll() {
return this.usersRepository.findAndCount();
findAll(page:number) {
return this.usersRepository.findAndCount({
skip: page * 10,
take: 10,
order: {
version: 'DESC',
},
});
}
async findOne(id: string) {
const coa = await this.coaService.findByUser(id,coaType.WALLET);
try {
const userData = await this.usersRepository.findOneOrFail(id);
const userData = await this.usersRepository.findOneOrFail({
where: {
id: id
},
relations:["roles","superior"]
});
return {
...userData,
wallet:coa.amount,