Initial commit: 智能项目定价模型
This commit is contained in:
69
后端服务/app/models/competitor.py
Normal file
69
后端服务/app/models/competitor.py
Normal file
@@ -0,0 +1,69 @@
|
||||
"""竞品机构模型
|
||||
|
||||
管理周边竞品医美机构信息
|
||||
"""
|
||||
|
||||
from typing import Optional, List, TYPE_CHECKING
|
||||
from decimal import Decimal
|
||||
|
||||
from sqlalchemy import String, Boolean, DECIMAL
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.models.base import BaseModel
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from app.models.competitor_price import CompetitorPrice
|
||||
|
||||
|
||||
class Competitor(BaseModel):
|
||||
"""竞品机构表"""
|
||||
|
||||
__tablename__ = "competitors"
|
||||
|
||||
competitor_name: Mapped[str] = mapped_column(
|
||||
String(100),
|
||||
nullable=False,
|
||||
comment="机构名称"
|
||||
)
|
||||
address: Mapped[Optional[str]] = mapped_column(
|
||||
String(200),
|
||||
nullable=True,
|
||||
comment="地址"
|
||||
)
|
||||
distance_km: Mapped[Optional[Decimal]] = mapped_column(
|
||||
DECIMAL(5, 2),
|
||||
nullable=True,
|
||||
comment="距离(公里)"
|
||||
)
|
||||
positioning: Mapped[str] = mapped_column(
|
||||
String(20),
|
||||
nullable=False,
|
||||
default="medium",
|
||||
index=True,
|
||||
comment="定位:high-高端, medium-中端, budget-大众"
|
||||
)
|
||||
contact: Mapped[Optional[str]] = mapped_column(
|
||||
String(50),
|
||||
nullable=True,
|
||||
comment="联系方式"
|
||||
)
|
||||
is_key_competitor: Mapped[bool] = mapped_column(
|
||||
Boolean,
|
||||
nullable=False,
|
||||
default=False,
|
||||
index=True,
|
||||
comment="是否重点关注"
|
||||
)
|
||||
is_active: Mapped[bool] = mapped_column(
|
||||
Boolean,
|
||||
nullable=False,
|
||||
default=True,
|
||||
comment="是否启用"
|
||||
)
|
||||
|
||||
# 关系
|
||||
prices: Mapped[List["CompetitorPrice"]] = relationship(
|
||||
"CompetitorPrice",
|
||||
back_populates="competitor",
|
||||
cascade="all, delete-orphan"
|
||||
)
|
||||
Reference in New Issue
Block a user