feat: add page size in all the rest API

This commit is contained in:
caturbgs
2021-12-22 15:23:05 +07:00
parent cdd6d39c90
commit c3df45dc9a
14 changed files with 135 additions and 124 deletions

View File

@@ -1,19 +1,7 @@
import {
forwardRef,
HttpException,
HttpStatus,
Inject,
Injectable,
} from '@nestjs/common';
import { forwardRef, HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common';
import { CreateUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import {
Connection,
EntityNotFoundError,
Equal,
Not,
Repository,
} from 'typeorm';
import { Connection, EntityNotFoundError, Not, Repository } from 'typeorm';
import { User } from './entities/user.entity';
import { InjectRepository } from '@nestjs/typeorm';
import { randomStringGenerator } from '@nestjs/common/utils/random-string-generator.util';
@@ -155,10 +143,10 @@ export class UsersService {
};
}
findByRoles(relationId: string, page: number) {
findByRoles(relationId: string, page: number, pageSize?: number) {
return this.usersRepository.findAndCount({
skip: page * 10,
take: 10,
skip: page * (pageSize || 10),
take: pageSize || 10,
where: {
roles: relationId,
},