Files
smart-project-pricing/后端服务/app/models/competitor.py
2026-01-31 21:33:06 +08:00

70 lines
1.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""竞品机构模型
管理周边竞品医美机构信息
"""
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"
)