feat: CRUD for product barcode images

This commit is contained in:
2024-11-01 17:23:58 +04:00
parent cbe3697f1b
commit 5ed42d99dc
11 changed files with 210 additions and 4 deletions

View File

@@ -23,6 +23,8 @@ class Product(BaseModel):
barcode_template_id = Column(Integer, ForeignKey('barcode_templates.id'), nullable=True)
barcode_template = relationship('BarcodeTemplate', lazy='joined')
barcode_image = relationship('ProductBarcodeImage', back_populates='product', lazy='joined', uselist=False)
# Attributes
# TODO move to another table
brand = Column(String, nullable=True, comment='Бренд')
@@ -61,3 +63,11 @@ class ProductBarcode(BaseModel):
product: Mapped["Product"] = relationship(back_populates='barcodes')
barcode = Column(String, nullable=False, index=True, comment='ШК товара', primary_key=True)
class ProductBarcodeImage(BaseModel):
__tablename__ = 'product_barcode_images'
product_id = Column(Integer, ForeignKey('products.id'), primary_key=True, comment='ID товара')
product: Mapped["Product"] = relationship(back_populates='barcode_image')
filename = Column(String, nullable=False)