fix: order product

This commit is contained in:
ilham
2021-12-15 08:51:05 +07:00
parent e8bbc1e554
commit 53575f36d6
9 changed files with 125 additions and 54 deletions

View File

@@ -20,6 +20,7 @@ import { ProductSubCategoriesService } from './product-sub-categories.service';
import { CreateSubCategoriesProductDto } from './dto/sub-categories/create-sub-categories-product.dto';
import { CreateProductDto } from './dto/product/create-product.dto';
import { UpdateProductDto } from './dto/product/update-product.dto';
import { ProductHistoryPriceService } from './history-price/history-price.service';
@Controller({
path: 'product',
@@ -30,6 +31,7 @@ export class ProductController {
private readonly productService: ProductService,
private readonly productCategoriesService: ProductCategoriesService,
private readonly productSubCategoriesService: ProductSubCategoriesService,
private readonly productHistoryPriceService: ProductHistoryPriceService,
) {}
@Post()
@@ -79,6 +81,20 @@ export class ProductController {
};
}
@Get('test')
async test(@Request() req) {
const data = await this.productHistoryPriceService.findOne(
'4d3b328c-3ce4-4c84-84bb-cd9c36e85a45',
'27effb3e-0351-428a-ba7f-08a21c54e16a',
);
return {
data,
statusCode: HttpStatus.OK,
message: 'success',
};
}
@Get('by-categories-all')
async findByCategoriesAll(
@Query('page') page: number,

View File

@@ -9,6 +9,7 @@ import { ProductHistoryPrice } from './entities/product-history-price.entity';
import { ProductSubCategories } from './entities/product-sub-category.entity';
import { ProductSubCategoriesService } from './product-sub-categories.service';
import { UsersModule } from '../users/users.module';
import { ProductHistoryPriceService } from './history-price/history-price.service';
@Module({
imports: [
@@ -25,7 +26,8 @@ import { UsersModule } from '../users/users.module';
ProductService,
ProductCategoriesService,
ProductSubCategoriesService,
ProductHistoryPriceService,
],
exports: [ProductService],
exports: [ProductService, ProductHistoryPriceService],
})
export class ProductModule {}

View File

@@ -13,7 +13,6 @@ import { UpdateProductDto } from './dto/product/update-product.dto';
import { ProductHistoryPrice } from './entities/product-history-price.entity';
import { productType } from '../helper/enum-list';
import { UpdatePriceProductDto } from './dto/product/update-price-product.dto';
import { Raw } from 'typeorm/browser';
import { UsersService } from '../users/users.service';
import { SupplierService } from '../users/supplier/supplier.service';
@@ -132,7 +131,12 @@ export class ProductService {
async findOne(code: string) {
try {
return await this.productRepository.findOneOrFail({ code: code });
return await this.productRepository.findOneOrFail({
relations: ['supplier'],
where: {
code: code,
},
});
} catch (e) {
if (e instanceof EntityNotFoundError) {
throw new HttpException(