add:product price
This commit is contained in:
@@ -5,11 +5,18 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { CreateProductDto } from '../product/dto/product/create-product.dto';
|
||||
import { ProductSubCategoriesService } from './product-sub-categories.service';
|
||||
import { UpdateProductDto } from './dto/product/update-product.dto';
|
||||
import { ProductHistoryPrice } from './entities/product-history-price.entity';
|
||||
|
||||
enum Type {
|
||||
NORMAL,
|
||||
PROMO,
|
||||
}
|
||||
|
||||
export class ProductService {
|
||||
constructor(
|
||||
@InjectRepository(Product)
|
||||
private productRepository: Repository<Product>,
|
||||
private productHistoryPrice: Repository<ProductHistoryPrice>,
|
||||
private productSubCategoriesService: ProductSubCategoriesService,
|
||||
) {}
|
||||
|
||||
@@ -23,6 +30,14 @@ export class ProductService {
|
||||
code: createProductDto.code,
|
||||
status: createProductDto.status,
|
||||
subCategories: subCategories,
|
||||
price: createProductDto.price,
|
||||
});
|
||||
|
||||
await this.productHistoryPrice.insert({
|
||||
product: result.identifiers[0],
|
||||
type: Type.NORMAL,
|
||||
startDate: new Date(),
|
||||
endDate: null,
|
||||
});
|
||||
|
||||
return this.productRepository.findOneOrFail(result.identifiers[0].id);
|
||||
@@ -81,6 +96,7 @@ export class ProductService {
|
||||
code: updateProductDto.code,
|
||||
status: updateProductDto.status,
|
||||
subCategories: subCategories,
|
||||
price: updateProductDto.price,
|
||||
});
|
||||
|
||||
return this.productRepository.findOneOrFail(id);
|
||||
|
||||
Reference in New Issue
Block a user