123
This commit is contained in:
60
database/sipro/models/products.py
Normal file
60
database/sipro/models/products.py
Normal file
@@ -0,0 +1,60 @@
|
||||
from sqlalchemy import ForeignKey
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from .base import BaseSiproModel
|
||||
from .general import Marketplace
|
||||
|
||||
|
||||
class Product(BaseSiproModel):
|
||||
__tablename__ = 'products'
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
denco_article: Mapped[int] = mapped_column(index=True)
|
||||
article: Mapped[str] = mapped_column(index=True)
|
||||
|
||||
|
||||
class MarketplaceProduct(BaseSiproModel):
|
||||
__tablename__ = 'marketplace_products'
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
marketplace_id: Mapped[int] = mapped_column(ForeignKey('marketplaces.id'))
|
||||
marketplace: Mapped["Marketplace"] = relationship()
|
||||
mp_price_bought: Mapped[int] = mapped_column()
|
||||
price_recommended: Mapped[int] = mapped_column()
|
||||
is_archived: Mapped[bool] = mapped_column()
|
||||
|
||||
product_id: Mapped[int] = mapped_column(ForeignKey("products.id"))
|
||||
product: Mapped["Product"] = relationship()
|
||||
|
||||
|
||||
class SupplierProduct(BaseSiproModel):
|
||||
__tablename__ = 'supplier_products'
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
supplier_stock: Mapped[int] = mapped_column()
|
||||
supplier_id: Mapped[int] = mapped_column()
|
||||
|
||||
product_id: Mapped[int] = mapped_column(ForeignKey("products.id"))
|
||||
product: Mapped["Product"] = relationship()
|
||||
|
||||
in_block: Mapped[int] = mapped_column()
|
||||
|
||||
|
||||
class CompanyWarehouseProduct(BaseSiproModel):
|
||||
__tablename__ = 'company_warehouse_products'
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
is_sold: Mapped[bool] = mapped_column()
|
||||
company_warehouse_id: Mapped[int] = mapped_column()
|
||||
|
||||
product_id: Mapped[int] = mapped_column(ForeignKey("products.id"))
|
||||
product: Mapped["Product"] = relationship()
|
||||
|
||||
|
||||
class ProductRelation(BaseSiproModel):
|
||||
__tablename__ = "products_relations"
|
||||
id: Mapped[int] = mapped_column(primary_key=True, comment="ID связи в БД")
|
||||
|
||||
master_product_id: Mapped[int] = mapped_column(ForeignKey("products.id"))
|
||||
master_product: Mapped["Product"] = relationship(foreign_keys=[master_product_id])
|
||||
|
||||
slave_product_id: Mapped[int] = mapped_column(ForeignKey("products.id"))
|
||||
slave_product: Mapped["Product"] = relationship(foreign_keys=[slave_product_id])
|
||||
|
||||
relation_type: Mapped[int] = mapped_column(comment="Тип связи (ENUM)")
|
||||
Reference in New Issue
Block a user