feat: rewrite filter for product
This commit is contained in:
@@ -47,16 +47,7 @@ export class ProductService {
|
||||
return this.productRepository.findOneOrFail(result.identifiers[0].id);
|
||||
}
|
||||
|
||||
async findAll(page: number, supplier: string, subCategories: string) {
|
||||
let filterSupplier = [];
|
||||
let filterSubCategories = [];
|
||||
|
||||
if (supplier !== 'null') {
|
||||
filterSupplier = supplier.split(',').map((data) => data.trim());
|
||||
}
|
||||
if (subCategories !== 'null') {
|
||||
filterSubCategories = subCategories.split(',').map((data) => data.trim());
|
||||
}
|
||||
async findAll(page: number, supplier: [], subCategories: []) {
|
||||
// if (supplier.length > 0) {
|
||||
// const dataSupplier = await this.supplierService.findByActiveAll();
|
||||
// supplier = dataSupplier.map((item) => item.id);
|
||||
@@ -87,15 +78,15 @@ export class ProductService {
|
||||
// .addSelect('current_price.price')
|
||||
// .addSelect('(current_price.price + current_price.mark_up_price) as mark_up_price');
|
||||
|
||||
if (filterSubCategories.length > 0) {
|
||||
if (subCategories.length > 0) {
|
||||
baseQuery.where('product.sub_categories_id IN (:...subCategoryId)', {
|
||||
subCategoryId: filterSubCategories,
|
||||
subCategoryId: subCategories,
|
||||
});
|
||||
}
|
||||
|
||||
if (filterSupplier.length > 0) {
|
||||
if (supplier.length > 0) {
|
||||
baseQuery.where('supplier.id IN (:...supplierId)', {
|
||||
supplierId: filterSupplier,
|
||||
supplierId: supplier,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user