add: callback transaction

This commit is contained in:
ilham
2021-12-26 00:43:27 +07:00
parent c5e1df20b8
commit 4f50bad562
10 changed files with 384 additions and 71 deletions

View File

@@ -10,6 +10,12 @@ export class ProductHistoryPriceService {
private productHistoryPriceService: Repository<ProductHistoryPrice>,
) {}
async create(dataProduct: ProductHistoryPrice) {
const result = await this.productHistoryPriceService.save(dataProduct);
return result;
}
async findOne(product: string, partner: string) {
try {
return await this.productHistoryPriceService.findOneOrFail({
@@ -34,6 +40,24 @@ export class ProductHistoryPriceService {
}
}
async findById(id: string) {
try {
return await this.productHistoryPriceService.findOneOrFail(id);
} catch (e) {
if (e instanceof EntityNotFoundError) {
throw new HttpException(
{
statusCode: HttpStatus.NOT_FOUND,
error: 'Price not found',
},
HttpStatus.NOT_FOUND,
);
} else {
throw e;
}
}
}
async findOneByProductId(
page: number,
productId: string,