Your Name 4a3c7e7923 refactor: 清理无用模块、修复前后端对齐、添加注册页面
- 删除后端 risk_exceptions 模块(API/Model/Schema/迁移/测试)
- 删除后端 metrics 模块(API/测试)
- 删除后端 ManualTask 模型和相关 Schema
- 修复搜索接口响应缺少 total 字段的问题
- 统一 Platform 枚举(前端去掉后端不支持的 weibo/wechat)
- 新增前端注册页面 /register,登录页添加注册链接

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 14:51:17 +08:00

53 lines
1.5 KiB
Python

"""
租户模型
"""
from typing import TYPE_CHECKING
from sqlalchemy import String, Boolean
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.models.base import Base, TimestampMixin
if TYPE_CHECKING:
from app.models.ai_config import AIConfig
from app.models.review import ReviewTask
from app.models.rule import ForbiddenWord, WhitelistItem, Competitor
class Tenant(Base, TimestampMixin):
"""租户表"""
__tablename__ = "tenants"
id: Mapped[str] = mapped_column(String(64), primary_key=True)
name: Mapped[str] = mapped_column(String(255), nullable=False)
is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
# 关联关系
ai_config: Mapped["AIConfig"] = relationship(
"AIConfig",
back_populates="tenant",
uselist=False,
lazy="selectin",
)
review_tasks: Mapped[list["ReviewTask"]] = relationship(
"ReviewTask",
back_populates="tenant",
lazy="selectin",
)
forbidden_words: Mapped[list["ForbiddenWord"]] = relationship(
"ForbiddenWord",
back_populates="tenant",
lazy="selectin",
)
whitelist_items: Mapped[list["WhitelistItem"]] = relationship(
"WhitelistItem",
back_populates="tenant",
lazy="selectin",
)
competitors: Mapped[list["Competitor"]] = relationship(
"Competitor",
back_populates="tenant",
lazy="selectin",
)
def __repr__(self) -> str:
return f"<Tenant(id={self.id}, name={self.name})>"