Files
Fulfillment-Backend/models/secondary.py
2024-05-09 01:32:37 +03:00

59 lines
2.3 KiB
Python

from sqlalchemy import Table, Column, Integer, ForeignKey
from sqlalchemy.orm import relationship
from models.base import metadata, BaseModel
class DealService(BaseModel):
__tablename__ = 'deal_services'
deal_id = Column(Integer, ForeignKey('deals.id'),
nullable=False,
comment='ID Сделки',
primary_key=True)
deal = relationship('Deal', back_populates='services')
service_id = Column(Integer, ForeignKey('services.id'), nullable=False, comment='ID Услуги', primary_key=True)
service = relationship('Service')
quantity = Column(Integer, nullable=False, comment='Кол-во услуги')
class DealProduct(BaseModel):
__tablename__ = 'deal_products'
deal_id = Column(Integer,
ForeignKey('deals.id'),
nullable=False,
comment='ID Сделки',
primary_key=True)
deal = relationship('Deal', back_populates='products')
product_id = Column(Integer, ForeignKey('products.id'), nullable=False, comment='ID Продукта', primary_key=True)
product = relationship('Product')
quantity = Column(Integer, nullable=False, comment='Кол-во продукта')
# class BarcodeTemplateAttributeLink(BaseModel):
# __tablename__ = 'barcode_template_attributes_links'
# barcode_template_id = Column(Integer,
# ForeignKey('barcode_templates.id'),
# nullable=False,
# comment='ID Шаблона ШК',
# primary_key=True)
# barcode_template = relationship('BarcodeTemplate',
# # back_populates='attributes'
# )
#
# attribute_id = Column(Integer,
# ForeignKey('barcode_template_attributes.id'),
# nullable=False,
# comment='ID Атрибута',
# primary_key=True)
# attribute = relationship('BarcodeTemplateAttribute')
barcode_template_attribute_link = Table(
'barcode_template_attribute_links',
BaseModel.metadata,
Column('barcode_template_id', ForeignKey('barcode_templates.id')),
Column('attribute_id', ForeignKey('barcode_template_attributes.id'))
)