fix: removed crap, category on service and deal
This commit is contained in:
@@ -9,7 +9,7 @@ from .marketplace import BaseMarketplace
|
||||
from .shipping_warehouse import ShippingWarehouse
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import DealBillRequest
|
||||
from . import DealBillRequest, ServicePriceCategory
|
||||
|
||||
|
||||
@unique
|
||||
@@ -23,6 +23,12 @@ class DealStatus(IntEnum):
|
||||
CANCELLED = 6
|
||||
|
||||
|
||||
class DealPriceCategory(BaseModel):
|
||||
__tablename__ = 'deal_price_category'
|
||||
deal_id: Mapped[int] = mapped_column(ForeignKey('deals.id'), primary_key=True, unique=True)
|
||||
category_id: Mapped[int] = mapped_column(ForeignKey('service_price_category.id'), primary_key=True)
|
||||
|
||||
|
||||
class Deal(BaseModel):
|
||||
__tablename__ = 'deals'
|
||||
id = Column(Integer, autoincrement=True, primary_key=True, index=True)
|
||||
@@ -64,6 +70,9 @@ class Deal(BaseModel):
|
||||
|
||||
comment = Column(String, nullable=False, server_default='', comment='Коментарий к заданию')
|
||||
bill_request: Mapped[Optional['DealBillRequest']] = relationship(back_populates='deal', lazy='joined')
|
||||
category: Mapped[Optional["ServicePriceCategory"]] = relationship('ServicePriceCategory',
|
||||
secondary=DealPriceCategory.__table__,
|
||||
lazy='joined')
|
||||
|
||||
|
||||
class DealStatusHistory(BaseModel):
|
||||
|
||||
@@ -42,6 +42,10 @@ class Service(BaseModel):
|
||||
lazy='selectin',
|
||||
order_by="asc(ServicePriceRange.from_quantity)",
|
||||
cascade="all, delete-orphan")
|
||||
category_prices = relationship('ServiceCategoryPrice',
|
||||
back_populates='service',
|
||||
lazy='selectin',
|
||||
cascade="all, delete-orphan")
|
||||
|
||||
|
||||
class ServicePriceRange(BaseModel):
|
||||
@@ -54,6 +58,23 @@ class ServicePriceRange(BaseModel):
|
||||
price = Column(Double, nullable=False, comment='Цена')
|
||||
|
||||
|
||||
class ServiceCategoryPrice(BaseModel):
|
||||
__tablename__ = 'service_category_prices'
|
||||
service_id: Mapped[int] = mapped_column(ForeignKey('services.id'), primary_key=True)
|
||||
category_id: Mapped[int] = mapped_column(ForeignKey('service_price_category.id'), primary_key=True)
|
||||
|
||||
price: Mapped[float] = mapped_column(Double, nullable=False, comment='Цена')
|
||||
|
||||
service: Mapped["Service"] = relationship('Service', lazy='joined', back_populates='category_prices')
|
||||
category: Mapped["ServicePriceCategory"] = relationship('ServicePriceCategory', lazy='joined')
|
||||
|
||||
|
||||
class ServicePriceCategory(BaseModel):
|
||||
__tablename__ = 'service_price_category'
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str] = mapped_column(nullable=False)
|
||||
|
||||
|
||||
class ServiceCategory(BaseModel):
|
||||
__tablename__ = 'service_categories'
|
||||
id = Column(Integer, autoincrement=True, primary_key=True, index=True)
|
||||
|
||||
Reference in New Issue
Block a user