8bfd0cfdc3
🛠️ Bug 修复: - backend/app/dependencies.py: 修 require_role 装饰器 问题:@wraps 让 FastAPI 看到 __wrapped__ 签名,Depends 默认值未被解析, current_user 实际是 Depends 对象 → 'Depends' object has no attribute 'roles' 修法:用 inspect 合并签名 + 手动设 wrapper.__signature__, 把 current_user 加进 FastAPI 看到的参数列表 影响:所有用 @require_role 的 endpoint 在生产都受影响,修后正常 📦 Dependencies: - backend/requirements.txt: pydantic 2.7.4 原因:2.7.5 被 PyPI yank,清华源不缓存,build 失败 (本次不进生产,但合并时一起跟) 🗃️ Alembic migrations(3 个,生产必跑): - 010_add_agent_otp: agents.otp_secret + agents.otp_enabled 背景:Agent 模型加了 OTP 字段但没建 migration,坐席登录报 'column agents.otp_secret does not exist' 字段:otp_secret VARCHAR(64) NULL, otp_enabled BOOLEAN DEFAULT false 安全:nullable + default,现有坐席不受影响 - 011_add_conversation_impact: conversations 3 个评估字段 背景:坐席发消息 500 报 'column conversations.impact_scope does not exist' 字段:impact_scope INT DEFAULT 0, is_blocking BOOL DEFAULT false, emotion_state VARCHAR(20) DEFAULT 'normal' 安全:都有 default,现有会话自动填默认值 - 012_sync_remaining_fields: 模型 vs DB 剩余漂移 背景:dev-check-schema-drift 找到 4 个 dev 模式下没暴露的字段 字段:conversations.dify_conversation_id VARCHAR(128) NULL, employees.it_level VARCHAR(20) DEFAULT 'silver', employees.it_level_source VARCHAR(20) DEFAULT 'system', employees.notes JSON DEFAULT '{}' 安全:都有 default,现有数据自动填默认值 部署: cd /app && python -m alembic upgrade head docker compose restart backend 验证:curl http://10.90.5.110:8000/health → 200
88 lines
3.8 KiB
Plaintext
88 lines
3.8 KiB
Plaintext
# =============================================================================
|
||
# 企微IT智能服务台 — Python 依赖声明
|
||
# =============================================================================
|
||
# 说明:列出后端所有 Python 包依赖及版本
|
||
# 用法:pip install -r requirements.txt
|
||
# =============================================================================
|
||
|
||
# --------------------------------------------------------------------------
|
||
# Web 框架
|
||
# --------------------------------------------------------------------------
|
||
# FastAPI: 高性能异步 Web 框架,自动生成 Swagger API 文档
|
||
fastapi==0.111.1
|
||
# Uvicorn: ASGI 服务器,支持热重载和 WebSocket
|
||
uvicorn[standard]==0.30.1
|
||
# python-multipart: FastAPI 文件上传支持(处理 multipart/form-data 请求)
|
||
python-multipart==0.0.12
|
||
|
||
# --------------------------------------------------------------------------
|
||
# 数据库
|
||
# --------------------------------------------------------------------------
|
||
# SQLAlchemy: Python SQL 工具包和 ORM,2.0 版本支持 async session
|
||
sqlalchemy==2.0.31
|
||
# psycopg2-binary: PostgreSQL 数据库驱动(binary 版本无需编译,用于 Alembic 同步迁移)
|
||
psycopg2-binary==2.9.9
|
||
# asyncpg: PostgreSQL 异步驱动(用于 SQLAlchemy 2.0 async engine)
|
||
asyncpg==0.29.0
|
||
# Alembic: 数据库迁移工具,与 SQLAlchemy 配合使用
|
||
alembic==1.13.1
|
||
|
||
# --------------------------------------------------------------------------
|
||
# 缓存
|
||
# --------------------------------------------------------------------------
|
||
# redis: Redis 客户端,用于 access_token 缓存和会话状态管理
|
||
redis==5.0.7
|
||
|
||
# --------------------------------------------------------------------------
|
||
# 数据验证
|
||
# --------------------------------------------------------------------------
|
||
# pydantic: 数据验证和设置管理,FastAPI 的核心依赖
|
||
# 注意:必须用 2.7.4 或 2.8.0+,2.7.5 被 PyPI yank(清华源/官方源都没有)
|
||
pydantic==2.7.4
|
||
# pydantic-settings: 从环境变量读取配置,支持 .env 文件
|
||
pydantic-settings==2.3.4
|
||
|
||
# --------------------------------------------------------------------------
|
||
# HTTP 客户端
|
||
# --------------------------------------------------------------------------
|
||
# httpx: 异步 HTTP 客户端,用于调用企微 API(替代同步的 requests)
|
||
httpx==0.27.0
|
||
|
||
# --------------------------------------------------------------------------
|
||
# 加密
|
||
# --------------------------------------------------------------------------
|
||
# cryptography: 企微消息 AES-CBC-256 加解密(官方推荐库)
|
||
cryptography==42.0.8
|
||
|
||
# --------------------------------------------------------------------------
|
||
# 速率限制
|
||
# --------------------------------------------------------------------------
|
||
# slowapi: FastAPI 速率限制中间件(基于 limits 库,支持 Redis 后端)
|
||
slowapi==0.1.9
|
||
|
||
# --------------------------------------------------------------------------
|
||
# 工具
|
||
# --------------------------------------------------------------------------
|
||
# python-dotenv: 从 .env 文件加载环境变量到 os.environ
|
||
python-dotenv==1.0.1
|
||
|
||
# --------------------------------------------------------------------------
|
||
# OTP 二次验证
|
||
# --------------------------------------------------------------------------
|
||
# pyotp: TOTP/HOTP 动态码生成和验证(Google Authenticator 兼容)
|
||
pyotp==2.9.0
|
||
# bcrypt: 密码哈希库(用于本地密码认证)
|
||
bcrypt==4.1.2
|
||
# passlib: 密码哈希兼容库(bcrypt 前端封装)
|
||
passlib[bcrypt]==1.7.4
|
||
# qrcode: 二维码生成(用于 OTP 绑定)
|
||
qrcode[pil]==7.4.2
|
||
# pillow: 图片处理(qrcode[pil] 依赖)
|
||
pillow==10.4.0
|
||
|
||
# --------------------------------------------------------------------------
|
||
# 监控
|
||
# --------------------------------------------------------------------------
|
||
# psutil: 系统监控(用于 /metrics 端点)
|
||
psutil==5.9.8
|