Files
BrunoGaoandClaude 3248bb0a2a feat: 完成消息系统V2优化 - 基于user_id的高性能索引重构
## 主要更改

### 1. 数据库表结构增强
- **t_device_message_v2**: 新增7个关键字段
  - priority_level: 优先级数值(1-5)
  - channels: 分发渠道JSON
  - require_ack: 是否需要确认
  - metadata: 扩展元数据JSON
  - target_count: 目标用户总数
  - version: 乐观锁版本号

- **t_device_message_detail_v2**: 新增8个关键字段
  - distribution_id: 分发唯一ID
  - device_sn: 设备序列号
  - user_id: 用户ID(核心查询字段)
  - response_duration: 响应耗时
  - delivery_details: 分发详情JSON
  - client_info: 客户端信息JSON
  - location_info: 位置信息JSON
  - last_retry_time: 最后重试时间

### 2. 索引优化重构 (基于user_id)
- 删除原有device_sn相关索引
- 新建5个user_id高性能复合索引:
  - idx_customer_user_time: 客户+用户+时间
  - idx_customer_user_status: 客户+用户+状态
  - idx_customer_user_type: 客户+用户+类型
  - idx_user_org_priority: 用户+组织+优先级
  - idx_user_status_time: 用户+状态+时间

- detail表新建4个user_id相关索引:
  - uk_message_user_target: 唯一约束
  - idx_customer_user_status: 客户+用户+状态
  - idx_user_channel_time: 用户+渠道+时间
  - idx_user_delivery_status: 用户+分发状态

### 3. 数据迁移和初始化
- 自动生成distribution_id
- 根据urgency设置priority_level
- 初始化默认channels配置
- 保持现有数据完整性

### 4. 性能提升预期
- 用户消息查询: 预计10-20倍性能提升
- 确认状态查询: 支持快速人员清单检索
- 存储空间: JSON字段替代冗余VARCHAR
- 查询覆盖: 所有user_id查询都能命中索引

### 5. 文档和脚本
- 完整的V2优化SQL脚本
- 消息机制设计文档
- 数据库备份(22MB)
- 性能验证查询

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
2025-09-15 07:56:03 +08:00
..
2025-08-27 15:56:11 +08:00
2025-08-27 15:56:11 +08:00
2025-08-14 08:11:03 +08:00
2025-08-14 08:11:03 +08:00
2025-08-27 15:56:11 +08:00
2025-08-14 08:11:03 +08:00
2025-08-27 15:56:11 +08:00

LjwxBoot Starter

SpringBoot JDK Version License
Author Copyright

基于项目:ljwx-boot

LjwxBoot Starter
├── ljwx-boot-starter-code-generate -- 代码生成
├── ljwx-boot-starter-common -- 基础模块
├── ljwx-boot-starter-database-mybatis-plus -- MyBatis Plus
├── ljwx-boot-starter-database-mysql -- MySQL 数据库
├── ljwx-boot-starter-database-redis -- Redis 缓存
├── ljwx-boot-starter-database-sharding -- Sharding 分表分库
├── ljwx-boot-starter-job-quartz -- Quartz 调度
├── ljwx-boot-starter-job-oss -- OSS 对象存储
├── ljwx-boot-starter-sa-token -- Sa Token 鉴权
└── pom.xml -- 公共依赖

开源协议

项目基于 Apache License 2.0 © 2024 ljwx 协议,仅供学习参考,商业使用请遵循作者版权信息,作者不保证也不承担任何软件的使用风险。