chore: initial baseline with P0-safety .gitignore

This commit is contained in:
Simon
2026-06-14 16:49:18 +08:00
commit 63262292d7
510 changed files with 146008 additions and 0 deletions
+120
View File
@@ -0,0 +1,120 @@
# =============================================================================
# 企微IT智能服务台 — 趣味话术模型
# =============================================================================
# 说明:对应数据库 funny_phrases 表,存储各场景的趣味话术
# 场景:shake(摇人)/keyword(关键词)/waiting(等待)/connected(接入)/timeout(超时)/vip
# 话术在用户端H5中显示,给等待过程增添趣味性
# =============================================================================
import uuid
from datetime import datetime
from sqlalchemy import Boolean, DateTime, Index, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from app.database import Base
class FunnyPhrase(Base):
"""趣味话术模型 — 对应 funny_phrases 表。
按触发场景存储趣味话术,在用户等待过程中显示。
支持后台动态修改,无需发版。
Attributes:
id: 话术唯一标识(UUID,数据库自动生成)
scene: 触发场景(shake/keyword/waiting/connected/timeout/vip
content: 话术内容
tone: 语气标签(亲切/稍正式/安抚/明确交接/降级安抚/正式)
sort_order: 排序权重
is_active: 是否启用
created_at: 创建时间
updated_at: 更新时间
"""
# 表名(必须和架构文档 DDL 一致)
__tablename__ = "funny_phrases"
# --------------------------------------------------------------------------
# 字段定义
# --------------------------------------------------------------------------
# 主键:UUIDPython端生成(兼容PostgreSQL和SQLite
id: Mapped[str] = mapped_column(
String(36),
primary_key=True,
default=lambda: str(uuid.uuid4()),
)
# 触发场景
# shake: 点击摇人按钮时
# keyword: 关键词触发转人工时
# waiting: 排队等待时(30秒无人接单)
# connected: 坐席接入时
# timeout: 等待超时时(2分钟)
# vip: VIP员工时
scene: Mapped[str] = mapped_column(
String(64),
nullable=False,
comment="触发场景: shake/keyword/waiting/connected/timeout/vip",
)
# 话术内容
content: Mapped[str] = mapped_column(
Text,
nullable=False,
comment="话术内容",
)
# 语气标签(方便管理员理解话术风格)
tone: Mapped[str] = mapped_column(
String(32),
nullable=False,
default="亲切",
comment="语气标签",
)
# 排序权重(同一场景下有多条话术时,按此排序)
sort_order: Mapped[int] = mapped_column(
Integer,
nullable=False,
default=0,
comment="排序权重",
)
# 是否启用(False 的话术不会被使用)
is_active: Mapped[bool] = mapped_column(
Boolean,
nullable=False,
default=True,
comment="是否启用",
)
# 创建时间
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
nullable=False,
default=datetime.now,
comment="创建时间",
)
# 更新时间
updated_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
nullable=False,
default=datetime.now,
onupdate=datetime.now,
comment="更新时间",
)
# --------------------------------------------------------------------------
# 索引定义(和架构文档 DDL 严格一致)
# --------------------------------------------------------------------------
__table_args__ = (
# 按场景查询(如获取所有"摇人"场景的话术)
Index("idx_fp_scene", "scene"),
)
def __repr__(self) -> str:
"""话术对象的字符串表示,方便调试。"""
return f"<FunnyPhrase(id={self.id}, scene={self.scene}, content={self.content[:20]})>"