feat: modules, products, services, services kits
This commit is contained in:
40
modules/fulfillment_base/models/product.py
Normal file
40
modules/fulfillment_base/models/product.py
Normal file
@ -0,0 +1,40 @@
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy import ForeignKey
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from models.base import BaseModel
|
||||
from models.mixins import IdMixin, SoftDeleteMixin
|
||||
|
||||
|
||||
class Product(BaseModel, IdMixin, SoftDeleteMixin):
|
||||
__tablename__ = "fulfillment_base_products"
|
||||
|
||||
name: Mapped[str] = mapped_column()
|
||||
article: Mapped[str] = mapped_column(index=True)
|
||||
factory_article: Mapped[str] = mapped_column(
|
||||
index=True, default="", server_default=""
|
||||
)
|
||||
brand: Mapped[Optional[str]] = mapped_column(comment="Бренд")
|
||||
color: Mapped[Optional[str]] = mapped_column(comment="Цвет")
|
||||
composition: Mapped[Optional[str]] = mapped_column(comment="Состав")
|
||||
size: Mapped[Optional[str]] = mapped_column(comment="Размер")
|
||||
additional_info: Mapped[Optional[str]] = mapped_column(
|
||||
comment="Дополнительная информация"
|
||||
)
|
||||
|
||||
images: Mapped[list["ProductImage"]] = relationship(
|
||||
"ProductImage",
|
||||
back_populates="product",
|
||||
lazy="selectin",
|
||||
cascade="all, delete-orphan",
|
||||
)
|
||||
|
||||
|
||||
class ProductImage(BaseModel, IdMixin):
|
||||
__tablename__ = "fulfillment_base_product_images"
|
||||
|
||||
product_id: Mapped[int] = mapped_column(ForeignKey("fulfillment_base_products.id"))
|
||||
product: Mapped["Product"] = relationship(back_populates="images")
|
||||
|
||||
image_url: Mapped[str] = mapped_column(nullable=False)
|
||||
Reference in New Issue
Block a user