feat: add page size in all the rest API
This commit is contained in:
parent
cdd6d39c90
commit
c3df45dc9a
|
@ -1,8 +1,6 @@
|
||||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||||
import { EntityNotFoundError, Repository } from 'typeorm';
|
import { EntityNotFoundError, Repository } from 'typeorm';
|
||||||
import { Roles } from './entities/roles.entity';
|
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { UpdateUserDto } from '../users/dto/update-user.dto';
|
|
||||||
import { CommissionSetting } from './entities/commission_setting.entity';
|
import { CommissionSetting } from './entities/commission_setting.entity';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -12,10 +10,10 @@ export class CommissionService {
|
||||||
private commissionRepository: Repository<CommissionSetting>,
|
private commissionRepository: Repository<CommissionSetting>,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
findAllCommission(page) {
|
findAllCommission(page, pageSize?) {
|
||||||
return this.commissionRepository.findAndCount({
|
return this.commissionRepository.findAndCount({
|
||||||
skip: page * 10,
|
skip: page * (pageSize || 10),
|
||||||
take: 10,
|
take: pageSize || 10,
|
||||||
order: {
|
order: {
|
||||||
version: 'DESC',
|
version: 'DESC',
|
||||||
},
|
},
|
||||||
|
|
|
@ -30,8 +30,11 @@ export class ConfigurableController {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Get('/roles')
|
@Get('/roles')
|
||||||
async findAll(@Query('page') page: number) {
|
async findAll(
|
||||||
const [data, count] = await this.roleService.findAllRoles(page);
|
@Query('page') page: number,
|
||||||
|
@Query('pageSize') pageSize: number,
|
||||||
|
) {
|
||||||
|
const [data, count] = await this.roleService.findAllRoles(page, pageSize);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
|
@ -42,8 +45,14 @@ export class ConfigurableController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('/commission')
|
@Get('/commission')
|
||||||
async findCommission(@Query('page') page: number) {
|
async findCommission(
|
||||||
const [data, count] = await this.commissionService.findAllCommission(page);
|
@Query('page') page: number,
|
||||||
|
@Query('pageSize') pageSize: number,
|
||||||
|
) {
|
||||||
|
const [data, count] = await this.commissionService.findAllCommission(
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
|
@ -54,9 +63,13 @@ export class ConfigurableController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('/roles/for-membership')
|
@Get('/roles/for-membership')
|
||||||
async findAllForMembership(@Query('page') page: number) {
|
async findAllForMembership(
|
||||||
|
@Query('page') page: number,
|
||||||
|
@Query('pageSize') pageSize: number,
|
||||||
|
) {
|
||||||
const [data, count] = await this.roleService.findAllRolesForCreateMember(
|
const [data, count] = await this.roleService.findAllRolesForCreateMember(
|
||||||
page,
|
page,
|
||||||
|
pageSize,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -10,20 +10,20 @@ export class RoleService {
|
||||||
private rolesRepository: Repository<Roles>,
|
private rolesRepository: Repository<Roles>,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
findAllRoles(page) {
|
findAllRoles(page, pageSize?) {
|
||||||
return this.rolesRepository.findAndCount({
|
return this.rolesRepository.findAndCount({
|
||||||
skip: page * 10,
|
skip: page * (pageSize || 10),
|
||||||
take: 10,
|
take: pageSize || 10,
|
||||||
order: {
|
order: {
|
||||||
version: 'DESC',
|
version: 'DESC',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
findAllRolesForCreateMember(page) {
|
findAllRolesForCreateMember(page, pageSize?) {
|
||||||
return this.rolesRepository.findAndCount({
|
return this.rolesRepository.findAndCount({
|
||||||
skip: page * 10,
|
skip: page * (pageSize || 10),
|
||||||
take: 10,
|
take: pageSize || 10,
|
||||||
where: {
|
where: {
|
||||||
id: Not(
|
id: Not(
|
||||||
In([
|
In([
|
||||||
|
|
|
@ -38,6 +38,7 @@ export class ProductHistoryPriceService {
|
||||||
page: number,
|
page: number,
|
||||||
productId: string,
|
productId: string,
|
||||||
supplierId: string,
|
supplierId: string,
|
||||||
|
pageSize?: number,
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const query = this.productHistoryPriceService
|
const query = this.productHistoryPriceService
|
||||||
|
@ -54,8 +55,8 @@ export class ProductHistoryPriceService {
|
||||||
|
|
||||||
const data = await query
|
const data = await query
|
||||||
.orderBy('product_history_price.createdAt', 'DESC')
|
.orderBy('product_history_price.createdAt', 'DESC')
|
||||||
.skip(page * 10)
|
.skip(page * (pageSize || 10))
|
||||||
.take(10)
|
.take(pageSize || 10)
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
const totalData = await query.getCount();
|
const totalData = await query.getCount();
|
||||||
|
|
|
@ -36,10 +36,10 @@ export class ProductCategoriesService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
findAll(page) {
|
findAll(page, pageSize?) {
|
||||||
return this.productCategoriesRepository.findAndCount({
|
return this.productCategoriesRepository.findAndCount({
|
||||||
skip: page * 10,
|
skip: page * (pageSize || 10),
|
||||||
take: 10,
|
take: pageSize || 10,
|
||||||
order: {
|
order: {
|
||||||
version: 'DESC',
|
version: 'DESC',
|
||||||
},
|
},
|
||||||
|
|
|
@ -44,7 +44,7 @@ export class ProductSubCategoriesService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async findAll(page, category: string) {
|
async findAll(page, category: string, pageSize?) {
|
||||||
let filterCategories;
|
let filterCategories;
|
||||||
if (category) {
|
if (category) {
|
||||||
filterCategories = category.split(',').map((data) => data.trim());
|
filterCategories = category.split(',').map((data) => data.trim());
|
||||||
|
@ -61,8 +61,8 @@ export class ProductSubCategoriesService {
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await baseQuery
|
const data = await baseQuery
|
||||||
.skip(page * 10)
|
.skip(page * (pageSize || 10))
|
||||||
.take(10)
|
.take(pageSize || 10)
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
const totalData = await baseQuery.getCount();
|
const totalData = await baseQuery.getCount();
|
||||||
|
|
|
@ -72,6 +72,7 @@ export class ProductController {
|
||||||
@Get('all')
|
@Get('all')
|
||||||
async findAll(
|
async findAll(
|
||||||
@Query('page') page: number,
|
@Query('page') page: number,
|
||||||
|
@Query('pageSize') pageSize: number,
|
||||||
@Query('sub-category') subcategory: string,
|
@Query('sub-category') subcategory: string,
|
||||||
@Query('supplier') supplier: string,
|
@Query('supplier') supplier: string,
|
||||||
) {
|
) {
|
||||||
|
@ -79,6 +80,7 @@ export class ProductController {
|
||||||
page,
|
page,
|
||||||
supplier == 'null' ? null : supplier,
|
supplier == 'null' ? null : supplier,
|
||||||
subcategory == 'null' ? null : subcategory,
|
subcategory == 'null' ? null : subcategory,
|
||||||
|
pageSize,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -105,6 +107,7 @@ export class ProductController {
|
||||||
@Get('by-categories-all')
|
@Get('by-categories-all')
|
||||||
async findByCategoriesAll(
|
async findByCategoriesAll(
|
||||||
@Query('page') page: number,
|
@Query('page') page: number,
|
||||||
|
@Query('pageSize') pageSize: number,
|
||||||
@Query('sub-category') subcategory: string,
|
@Query('sub-category') subcategory: string,
|
||||||
@Query('supplier') supplier: string,
|
@Query('supplier') supplier: string,
|
||||||
) {
|
) {
|
||||||
|
@ -112,6 +115,7 @@ export class ProductController {
|
||||||
page,
|
page,
|
||||||
subcategory,
|
subcategory,
|
||||||
supplier,
|
supplier,
|
||||||
|
pageSize,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -143,8 +147,14 @@ export class ProductController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('categories')
|
@Get('categories')
|
||||||
async findAllCategories(@Query('page') page: number) {
|
async findAllCategories(
|
||||||
const [data, count] = await this.productCategoriesService.findAll(page);
|
@Query('page') page: number,
|
||||||
|
@Query('pageSize') pageSize: number,
|
||||||
|
) {
|
||||||
|
const [data, count] = await this.productCategoriesService.findAll(
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
|
@ -157,11 +167,13 @@ export class ProductController {
|
||||||
@Get('sub-categories')
|
@Get('sub-categories')
|
||||||
async findAllSubCategories(
|
async findAllSubCategories(
|
||||||
@Query('page') page: number,
|
@Query('page') page: number,
|
||||||
|
@Query('pageSize') pageSize: number,
|
||||||
@Query('category') category: string,
|
@Query('category') category: string,
|
||||||
) {
|
) {
|
||||||
const data = await this.productSubCategoriesService.findAll(
|
const data = await this.productSubCategoriesService.findAll(
|
||||||
page,
|
page,
|
||||||
category == 'null' ? null : category,
|
category == 'null' ? null : category,
|
||||||
|
pageSize,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -184,12 +196,14 @@ export class ProductController {
|
||||||
async findPriceHistoryByProductId(
|
async findPriceHistoryByProductId(
|
||||||
@Param('id', ParseUUIDPipe) id: string,
|
@Param('id', ParseUUIDPipe) id: string,
|
||||||
@Query('page') page: number,
|
@Query('page') page: number,
|
||||||
|
@Query('pageSize') pageSize: number,
|
||||||
@Query('supplier') supplier: string,
|
@Query('supplier') supplier: string,
|
||||||
) {
|
) {
|
||||||
const data = await this.productHistoryPriceService.findOneByProductId(
|
const data = await this.productHistoryPriceService.findOneByProductId(
|
||||||
page,
|
page,
|
||||||
id,
|
id,
|
||||||
supplier,
|
supplier,
|
||||||
|
pageSize,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -47,7 +47,12 @@ export class ProductService {
|
||||||
return this.productRepository.findOneOrFail(result.identifiers[0].id);
|
return this.productRepository.findOneOrFail(result.identifiers[0].id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async findAll(page: number, supplier: string, subCategories: string) {
|
async findAll(
|
||||||
|
page: number,
|
||||||
|
supplier: string,
|
||||||
|
subCategories: string,
|
||||||
|
pageSize?: number,
|
||||||
|
) {
|
||||||
let filterSupplier, filterSubCategories;
|
let filterSupplier, filterSubCategories;
|
||||||
|
|
||||||
if (supplier) {
|
if (supplier) {
|
||||||
|
@ -61,10 +66,6 @@ export class ProductService {
|
||||||
return data.trim();
|
return data.trim();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// if (supplier.length > 0) {
|
|
||||||
// const dataSupplier = await this.supplierService.findByActiveAll();
|
|
||||||
// supplier = dataSupplier.map((item) => item.id);
|
|
||||||
// }
|
|
||||||
|
|
||||||
const baseQuery = this.productRepository
|
const baseQuery = this.productRepository
|
||||||
.createQueryBuilder('product')
|
.createQueryBuilder('product')
|
||||||
|
@ -72,9 +73,6 @@ export class ProductService {
|
||||||
.leftJoin('sub_categories.category', 'category')
|
.leftJoin('sub_categories.category', 'category')
|
||||||
.leftJoin('product.supplier', 'supplier')
|
.leftJoin('product.supplier', 'supplier')
|
||||||
.where('supplier.status = :status', { status: true })
|
.where('supplier.status = :status', { status: true })
|
||||||
// .where(`product.supplier_id = :supplier_id`, {
|
|
||||||
// supplier_id: In(supplier),
|
|
||||||
// })
|
|
||||||
.leftJoinAndMapOne(
|
.leftJoinAndMapOne(
|
||||||
'product.currentPrice',
|
'product.currentPrice',
|
||||||
'product.priceHistory',
|
'product.priceHistory',
|
||||||
|
@ -106,15 +104,9 @@ export class ProductService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (categories != 'null' && categories) {
|
|
||||||
// baseQuery.andWhere('sub_categories.category_id = :id', {
|
|
||||||
// id: categories,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
const data = await baseQuery
|
const data = await baseQuery
|
||||||
.offset(page * 10)
|
.offset(page * (pageSize || 10))
|
||||||
.limit(10)
|
.limit(pageSize || 10)
|
||||||
.getRawMany();
|
.getRawMany();
|
||||||
|
|
||||||
const totalData = await baseQuery.getCount();
|
const totalData = await baseQuery.getCount();
|
||||||
|
@ -156,7 +148,7 @@ export class ProductService {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async findAllBySubCategories(page, subCategories, supplier) {
|
async findAllBySubCategories(page, subCategories, supplier, pageSize?) {
|
||||||
if (supplier != 'null' && !supplier) {
|
if (supplier != 'null' && !supplier) {
|
||||||
supplier = (await this.supplierService.findByActive()).id;
|
supplier = (await this.supplierService.findByActive()).id;
|
||||||
}
|
}
|
||||||
|
@ -184,8 +176,8 @@ export class ProductService {
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await baseQuery
|
const data = await baseQuery
|
||||||
.skip(page * 10)
|
.skip(page * (pageSize || 10))
|
||||||
.take(10)
|
.take(pageSize || 10)
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
const totalData = await baseQuery.getCount();
|
const totalData = await baseQuery.getCount();
|
||||||
|
|
|
@ -1,17 +1,4 @@
|
||||||
import {
|
import { Body, Controller, Get, HttpStatus, Param, ParseUUIDPipe, Post, Put, Query, Request } from '@nestjs/common';
|
||||||
Controller,
|
|
||||||
Get,
|
|
||||||
Post,
|
|
||||||
Body,
|
|
||||||
Patch,
|
|
||||||
Param,
|
|
||||||
Delete,
|
|
||||||
Request,
|
|
||||||
HttpStatus,
|
|
||||||
Query,
|
|
||||||
Put,
|
|
||||||
ParseUUIDPipe,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { TransactionService } from './transaction.service';
|
import { TransactionService } from './transaction.service';
|
||||||
import { DistributeTransactionDto } from './dto/distribute-transaction.dto';
|
import { DistributeTransactionDto } from './dto/distribute-transaction.dto';
|
||||||
import { OrderTransactionDto } from './dto/order-transaction.dto';
|
import { OrderTransactionDto } from './dto/order-transaction.dto';
|
||||||
|
@ -101,10 +88,15 @@ export class TransactionController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('history')
|
@Get('history')
|
||||||
async findByCategories(@Query('page') page: number, @Request() req) {
|
async findByCategories(
|
||||||
|
@Query('page') page: number,
|
||||||
|
@Query('pageSize') pageSize: number,
|
||||||
|
@Request() req,
|
||||||
|
) {
|
||||||
const data = await this.transactionService.transactionHistoryByUser(
|
const data = await this.transactionService.transactionHistoryByUser(
|
||||||
page,
|
page,
|
||||||
req.user.userId,
|
req.user.userId,
|
||||||
|
pageSize,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -115,11 +107,16 @@ export class TransactionController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('deposit-return')
|
@Get('deposit-return')
|
||||||
async findDepositReturn(@Query('page') page: number, @Request() req) {
|
async findDepositReturn(
|
||||||
|
@Query('page') page: number,
|
||||||
|
@Query('pageSize') pageSize: number,
|
||||||
|
@Request() req,
|
||||||
|
) {
|
||||||
const [data, count] =
|
const [data, count] =
|
||||||
await this.transactionService.getAllDepositReturnFromUser(
|
await this.transactionService.getAllDepositReturnFromUser(
|
||||||
req.user.userId,
|
req.user.userId,
|
||||||
page,
|
page,
|
||||||
|
pageSize,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -133,12 +130,14 @@ export class TransactionController {
|
||||||
@Get('deposit-return/confirmation')
|
@Get('deposit-return/confirmation')
|
||||||
async findDepositReturnConfirmation(
|
async findDepositReturnConfirmation(
|
||||||
@Query('page') page: number,
|
@Query('page') page: number,
|
||||||
|
@Query('pageSize') pageSize: number,
|
||||||
@Request() req,
|
@Request() req,
|
||||||
) {
|
) {
|
||||||
const [data, count] =
|
const [data, count] =
|
||||||
await this.transactionService.getAllDepositReturnToUser(
|
await this.transactionService.getAllDepositReturnToUser(
|
||||||
req.user.userId,
|
req.user.userId,
|
||||||
page,
|
page,
|
||||||
|
pageSize,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -3,24 +3,14 @@ import { DistributeTransactionDto } from './dto/distribute-transaction.dto';
|
||||||
import { OrderTransactionDto } from './dto/order-transaction.dto';
|
import { OrderTransactionDto } from './dto/order-transaction.dto';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { Transactions } from './entities/transactions.entity';
|
import { Transactions } from './entities/transactions.entity';
|
||||||
import {
|
import { Connection, EntityNotFoundError, Repository } from 'typeorm';
|
||||||
Connection,
|
|
||||||
EntityManager,
|
|
||||||
EntityNotFoundError,
|
|
||||||
Repository,
|
|
||||||
} from 'typeorm';
|
|
||||||
import { COA } from './entities/coa.entity';
|
import { COA } from './entities/coa.entity';
|
||||||
import { TransactionJournal } from './entities/transaction-journal.entity';
|
import { TransactionJournal } from './entities/transaction-journal.entity';
|
||||||
import { CoaService } from './coa.service';
|
import { CoaService } from './coa.service';
|
||||||
import * as uuid from 'uuid';
|
import * as uuid from 'uuid';
|
||||||
import { uniq } from 'lodash';
|
import { uniq } from 'lodash';
|
||||||
import { Decimal } from 'decimal.js';
|
import { Decimal } from 'decimal.js';
|
||||||
import {
|
import { balanceType, coaType, statusTransaction, typeTransaction } from '../helper/enum-list';
|
||||||
balanceType,
|
|
||||||
coaType,
|
|
||||||
statusTransaction,
|
|
||||||
typeTransaction,
|
|
||||||
} from '../helper/enum-list';
|
|
||||||
import { ProductService } from '../product/product.service';
|
import { ProductService } from '../product/product.service';
|
||||||
import { CreateJournalDto } from './dto/create-journal.dto';
|
import { CreateJournalDto } from './dto/create-journal.dto';
|
||||||
import { UsersService } from 'src/users/users.service';
|
import { UsersService } from 'src/users/users.service';
|
||||||
|
@ -560,7 +550,11 @@ export class TransactionService {
|
||||||
return transactionData;
|
return transactionData;
|
||||||
}
|
}
|
||||||
|
|
||||||
async transactionHistoryByUser(page: number, user: string) {
|
async transactionHistoryByUser(
|
||||||
|
page: number,
|
||||||
|
user: string,
|
||||||
|
pageSize?: number,
|
||||||
|
) {
|
||||||
const baseQuery = this.transactionRepository
|
const baseQuery = this.transactionRepository
|
||||||
.createQueryBuilder('transaction')
|
.createQueryBuilder('transaction')
|
||||||
.select('transaction.id', 'id')
|
.select('transaction.id', 'id')
|
||||||
|
@ -578,8 +572,8 @@ export class TransactionService {
|
||||||
// .leftJoinAndSelect('product_price.product', 'product');
|
// .leftJoinAndSelect('product_price.product', 'product');
|
||||||
|
|
||||||
const data = await baseQuery
|
const data = await baseQuery
|
||||||
.skip(page * 10)
|
.offset(page * (pageSize || 10))
|
||||||
.take(10)
|
.limit(pageSize || 10)
|
||||||
.getRawMany();
|
.getRawMany();
|
||||||
|
|
||||||
const totalData = await baseQuery.getCount();
|
const totalData = await baseQuery.getCount();
|
||||||
|
@ -614,10 +608,14 @@ export class TransactionService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAllDepositReturnFromUser(user: string, page: number) {
|
async getAllDepositReturnFromUser(
|
||||||
|
user: string,
|
||||||
|
page: number,
|
||||||
|
pageSize?: number,
|
||||||
|
) {
|
||||||
return this.transactionRepository.findAndCount({
|
return this.transactionRepository.findAndCount({
|
||||||
skip: page * 10,
|
skip: page * (pageSize || 10),
|
||||||
take: 10,
|
take: pageSize || 10,
|
||||||
where: {
|
where: {
|
||||||
user: user,
|
user: user,
|
||||||
type: typeTransaction.DEPOSIT_RETURN,
|
type: typeTransaction.DEPOSIT_RETURN,
|
||||||
|
@ -628,10 +626,14 @@ export class TransactionService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAllDepositReturnToUser(user: string, page: number) {
|
async getAllDepositReturnToUser(
|
||||||
|
user: string,
|
||||||
|
page: number,
|
||||||
|
pageSize?: number,
|
||||||
|
) {
|
||||||
return this.transactionRepository.findAndCount({
|
return this.transactionRepository.findAndCount({
|
||||||
skip: page * 10,
|
skip: page * (pageSize || 10),
|
||||||
take: 10,
|
take: pageSize || 10,
|
||||||
where: {
|
where: {
|
||||||
user_destination: user,
|
user_destination: user,
|
||||||
type: typeTransaction.DEPOSIT_RETURN,
|
type: typeTransaction.DEPOSIT_RETURN,
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
import {
|
import { forwardRef, HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common';
|
||||||
forwardRef,
|
|
||||||
HttpException,
|
|
||||||
HttpStatus,
|
|
||||||
Inject,
|
|
||||||
Injectable,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { Connection, Not, Repository } from 'typeorm';
|
import { Connection, Not, Repository } from 'typeorm';
|
||||||
import { CoaService } from '../../transaction/coa.service';
|
import { CoaService } from '../../transaction/coa.service';
|
||||||
|
@ -135,10 +129,10 @@ export class PartnerService {
|
||||||
return partnerData;
|
return partnerData;
|
||||||
};
|
};
|
||||||
|
|
||||||
findAllPartner(page) {
|
findAllPartner(page, pageSize?) {
|
||||||
return this.partnerRepository.findAndCount({
|
return this.partnerRepository.findAndCount({
|
||||||
skip: page * 10,
|
skip: page * (pageSize || 10),
|
||||||
take: 10,
|
take: pageSize || 10,
|
||||||
order: {
|
order: {
|
||||||
version: 'DESC',
|
version: 'DESC',
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
import {
|
import { forwardRef, HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common';
|
||||||
forwardRef,
|
|
||||||
HttpException,
|
|
||||||
HttpStatus,
|
|
||||||
Inject,
|
|
||||||
Injectable,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { Connection, EntityNotFoundError, Not, Repository } from 'typeorm';
|
import { Connection, EntityNotFoundError, Not, Repository } from 'typeorm';
|
||||||
import { Supplier } from '../entities/supplier.entity';
|
import { Supplier } from '../entities/supplier.entity';
|
||||||
|
@ -130,7 +124,7 @@ export class SupplierService {
|
||||||
return supplierData;
|
return supplierData;
|
||||||
};
|
};
|
||||||
|
|
||||||
async findAllSupplier(page) {
|
async findAllSupplier(page, pageSize?) {
|
||||||
const baseQuery = this.supplierRepository
|
const baseQuery = this.supplierRepository
|
||||||
.createQueryBuilder('supplier')
|
.createQueryBuilder('supplier')
|
||||||
.leftJoinAndMapOne(
|
.leftJoinAndMapOne(
|
||||||
|
@ -148,8 +142,8 @@ export class SupplierService {
|
||||||
.select(['supplier', 'coa.amount', 'coa_undistribute.amount']);
|
.select(['supplier', 'coa.amount', 'coa_undistribute.amount']);
|
||||||
|
|
||||||
const data = await baseQuery
|
const data = await baseQuery
|
||||||
.skip(page * 10)
|
.skip(page * (pageSize || 10))
|
||||||
.take(10)
|
.take(pageSize || 10)
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
const totalData = await baseQuery.getCount();
|
const totalData = await baseQuery.getCount();
|
||||||
|
|
|
@ -125,8 +125,12 @@ export class UsersController {
|
||||||
|
|
||||||
@Public()
|
@Public()
|
||||||
@Get('supplier')
|
@Get('supplier')
|
||||||
async findAllSupplier(@Query('page') page: number) {
|
async findAllSupplier(
|
||||||
const data = await this.supplierService.findAllSupplier(page);
|
@Query('page') page: number,
|
||||||
|
@Query('pageSize') pageSize: number,
|
||||||
|
@Request() req,
|
||||||
|
) {
|
||||||
|
const data = await this.supplierService.findAllSupplier(page, pageSize);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...data,
|
...data,
|
||||||
|
@ -136,8 +140,15 @@ export class UsersController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('partner')
|
@Get('partner')
|
||||||
async findAllPartner(@Query('page') page: number) {
|
async findAllPartner(
|
||||||
const [data, count] = await this.partnerService.findAllPartner(page);
|
@Query('page') page: number,
|
||||||
|
@Query('pageSize') pageSize: number,
|
||||||
|
@Request() req,
|
||||||
|
) {
|
||||||
|
const [data, count] = await this.partnerService.findAllPartner(
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
|
@ -162,8 +173,13 @@ export class UsersController {
|
||||||
async findByRoles(
|
async findByRoles(
|
||||||
@Param('id', ParseUUIDPipe) id: string,
|
@Param('id', ParseUUIDPipe) id: string,
|
||||||
@Query('page') page: number,
|
@Query('page') page: number,
|
||||||
|
@Query('pageSize') pageSize: number,
|
||||||
) {
|
) {
|
||||||
const [data, count] = await this.usersService.findByRoles(id, page);
|
const [data, count] = await this.usersService.findByRoles(
|
||||||
|
id,
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
|
|
|
@ -1,19 +1,7 @@
|
||||||
import {
|
import { forwardRef, HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common';
|
||||||
forwardRef,
|
|
||||||
HttpException,
|
|
||||||
HttpStatus,
|
|
||||||
Inject,
|
|
||||||
Injectable,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { CreateUserDto } from './dto/create-user.dto';
|
import { CreateUserDto } from './dto/create-user.dto';
|
||||||
import { UpdateUserDto } from './dto/update-user.dto';
|
import { UpdateUserDto } from './dto/update-user.dto';
|
||||||
import {
|
import { Connection, EntityNotFoundError, Not, Repository } from 'typeorm';
|
||||||
Connection,
|
|
||||||
EntityNotFoundError,
|
|
||||||
Equal,
|
|
||||||
Not,
|
|
||||||
Repository,
|
|
||||||
} from 'typeorm';
|
|
||||||
import { User } from './entities/user.entity';
|
import { User } from './entities/user.entity';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { randomStringGenerator } from '@nestjs/common/utils/random-string-generator.util';
|
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({
|
return this.usersRepository.findAndCount({
|
||||||
skip: page * 10,
|
skip: page * (pageSize || 10),
|
||||||
take: 10,
|
take: pageSize || 10,
|
||||||
where: {
|
where: {
|
||||||
roles: relationId,
|
roles: relationId,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user