feat: product barcode images
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
from sqlalchemy import or_, delete
|
||||
from sqlalchemy.orm import selectinload, joinedload
|
||||
|
||||
from modules.fulfillment_base.models import Product, ProductBarcode, BarcodeTemplate
|
||||
from modules.fulfillment_base.models import Product, ProductBarcode, BarcodeTemplate, ProductBarcodeImage
|
||||
from modules.fulfillment_base.models.product import ProductImage
|
||||
from modules.fulfillment_base.schemas.product import (
|
||||
CreateProductSchema,
|
||||
@ -106,6 +106,13 @@ class ProductRepository(
|
||||
else:
|
||||
await self.session.flush()
|
||||
|
||||
async def delete_barcode_image(self, barcode_image: ProductBarcodeImage, with_commit: bool = False):
|
||||
await self.session.delete(barcode_image)
|
||||
if with_commit:
|
||||
await self.session.commit()
|
||||
else:
|
||||
await self.session.flush()
|
||||
|
||||
async def create_image(self, product_id: int, image_url: str) -> ProductImage:
|
||||
product_image = ProductImage(
|
||||
product_id=product_id,
|
||||
@ -114,3 +121,12 @@ class ProductRepository(
|
||||
self.session.add(product_image)
|
||||
await self.session.commit()
|
||||
return product_image
|
||||
|
||||
async def create_barcode_image(self, product_id: int, image_url: str) -> ProductBarcodeImage:
|
||||
product_barcode_image = ProductBarcodeImage(
|
||||
product_id=product_id,
|
||||
image_url=image_url,
|
||||
)
|
||||
self.session.add(product_barcode_image)
|
||||
await self.session.commit()
|
||||
return product_barcode_image
|
||||
|
||||
Reference in New Issue
Block a user