You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.6 KiB
1.6 KiB
Tasks: Config to MySQL
1. 数据模型与配置存储模块
- 1.1 在
app/models.py中新增AppConfig模型 - 1.2 创建
app/config_store.py,实现ConfigStore类 - 1.3 实现
get_config(key)方法,支持 MySQL → JSON 降级 - 1.4 实现
set_config(key, value)方法,支持 MySQL + JSON 双写 - 1.5 实现
_load_json(key, fallback)和_save_to_json(key, value)辅助方法
2. 数据迁移
- 2.1 创建
app/config_migration.py,实现migrate_configs_to_mysql() - 2.2 在
app/main.pylifespan 中创建app_config表 - 2.3 在
app/main.pylifespan 中调用迁移函数 - 2.4 迁移幂等性:数据库已有配置时跳过
3. 修改配置 API
- 3.1 修改
app/api/config.py使用ConfigStore读写symbols配置 - 3.2 修改
app/api/ai_config.py使用ConfigStore读写ai配置 - 3.3 保持 API 接口签名不变
4. 修改业务使用方
- 4.1 修改
app/api/futures_analysis.py从ConfigStore读取品种配置 - 4.2 修改
app/api/trade_review.py从ConfigStore读取品种配置 - 4.3 修改
app/services/trade_parser.py从ConfigStore读取品种配置 - 4.4 修改
app/services/plan_generator.py从ConfigStore读取品种配置 - 4.5 修改
app/services/ai_analysis.py从ConfigStore读取 AI 配置
5. 测试与验证
- 5.1 编写
tests/test_config_store.py,覆盖 MySQL 命中/未命中/降级场景 - 5.2 编写迁移测试,验证幂等性
- 5.3 运行全部测试套件,确保无回归(110 passed, 2 xfailed)
- 5.4 启动应用验证配置读取正常