admin
|
2a809eb7cc
|
refactor: complete data model v2.0 based on official API docs
数据模型全面重构,基于微信读书官方 8 份 API 文档逐字段比对:
1. 表结构从 18 张扩展到 31 张表:
新增表:shelf_albums(有声书)、shelf_meta(书架元信息)、prefer_publishers(偏好出版社)、
prefer_cps(偏好版权方)、prefer_books(偏好书籍卡片)、read_rank(好友排行)、
medals(勋章)、year_reports(年度报告)、book_best_bookmarks(热门划线)、
book_underlines(划线热度)、similar_books(相似推荐)、public_reviews(公开点评)、
search_sessions(搜索会话)
2. 补全所有遗漏字段:
- reading_stats: +13 个字段 (baseTime, compare, readRate, wrReadTime, wrListenTime 等)
- book_chapters: +8 个字段 (wordCount, level, price, paid, isMPChapter, anchors 等)
- book_reviews: +4 个字段 (abstract, range, chapterUid, chapterIdx)
- recommended_books: +5 个字段 (deepLink, searchIdx, price, payType, type)
- search_results: +8 个字段 (deepLink, payType, price, soldout, scope 等)
- book_details: +2 个字段 (deepLink, newRatingDetail)
- prefer_categories: +2 个字段 (parentCategoryId, categoryType)
3. 时间戳双列设计:
- 所有整型时间戳字段均伴随 _dt TIMESTAMP 列 (如 read_update_time + read_update_time_dt)
- 便于直接查询和展示,无需应用层转换
4. 审计字段:
- 每张表均维护 created_at 和 updated_at
- MySQL 使用 DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
5. 索引优化:
- 主键、唯一约束、查询索引根据实际访问模式重新设计
- 新增复合索引、排序索引、全文检索索引
6. 数据采集脚本更新:
- 覆盖所有新增表和字段的数据采集
- skill_version 升级至 1.0.4
- 有声书/专辑数据采集 (shelf_albums)
- 偏好出版社/版权方/书籍卡片采集
- 勋章、年度报告数据采集
7. 后端适配:
- 移除旧版 ensure_tables 动态建表逻辑
- 所有按需 API INSERT 语句适配新表结构
- 搜索结果入库新增 search_sessions 会话表
- 推荐书籍入库新增 batch_id 批次标识
|
2026-07-17 10:37:07 +08:00 |
|