cursor-init/tasks/M2-基础用户系统-开发任务计划.md
expressgy b2fe0925ef feat: 实现Token刷新接口
- 添加RefreshSchema定义刷新令牌验证规则

- 添加RefreshResponsesSchema定义响应格式

- 实现refresh方法处理Token刷新业务逻辑

- 添加/refresh路由支持Token刷新功能

关联任务4.0
2025-07-06 17:26:20 +08:00

353 lines
18 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# M2 - 基础用户系统 - 开发任务计划
## 相关文件 (Relevant Files)
### 认证模块 (Auth)
- `src/modules/auth/auth.schema.ts` - 认证模块Schema定义
- `src/modules/auth/auth.response.ts` - 认证模块响应格式定义
- `src/modules/auth/auth.service.ts` - 认证模块Service层实现
- `src/modules/auth/auth.controller.ts` - 认证模块Controller层实现
- `src/modules/auth/auth.test.md` - 认证模块测试用例文档
### 用户管理模块 (User)
- `src/modules/user/user.schema.ts` - 用户模块Schema定义已存在
- `src/modules/user/user.response.ts` - 用户模块响应格式定义(已存在)
- `src/modules/user/user.service.ts` - 用户模块Service层实现已存在
- `src/modules/user/user.controller.ts` - 用户模块Controller层实现需更新
- `src/modules/user/user.test.md` - 用户模块测试用例文档
### 角色权限模块 (Role)
- `src/modules/role/role.schema.ts` - 角色模块Schema定义
- `src/modules/role/role.response.ts` - 角色模块响应格式定义
- `src/modules/role/role.service.ts` - 角色模块Service层实现
- `src/modules/role/role.controller.ts` - 角色模块Controller层实现
- `src/modules/role/role.test.md` - 角色模块测试用例文档
### 权限管理模块 (Permission)
- `src/modules/permission/permission.schema.ts` - 权限模块Schema定义
- `src/modules/permission/permission.response.ts` - 权限模块响应格式定义
- `src/modules/permission/permission.service.ts` - 权限模块Service层实现
- `src/modules/permission/permission.controller.ts` - 权限模块Controller层实现
- `src/modules/permission/permission.test.md` - 权限模块测试用例文档
### 组织架构模块 (Organization)
- `src/modules/organization/organization.schema.ts` - 组织模块Schema定义
- `src/modules/organization/organization.response.ts` - 组织模块响应格式定义
- `src/modules/organization/organization.service.ts` - 组织模块Service层实现
- `src/modules/organization/organization.controller.ts` - 组织模块Controller层实现
- `src/modules/organization/organization.test.md` - 组织模块测试用例文档
### 系统基础模块 (System)
- `src/modules/system/dict/dict.schema.ts` - 字典模块Schema定义
- `src/modules/system/dict/dict.response.ts` - 字典模块响应格式定义
- `src/modules/system/dict/dict.service.ts` - 字典模块Service层实现
- `src/modules/system/dict/dict.controller.ts` - 字典模块Controller层实现
- `src/modules/system/dict/dict.test.md` - 字典模块测试用例文档
- `src/modules/system/tag/tag.schema.ts` - 标签模块Schema定义
- `src/modules/system/tag/tag.response.ts` - 标签模块响应格式定义
- `src/modules/system/tag/tag.service.ts` - 标签模块Service层实现
- `src/modules/system/tag/tag.controller.ts` - 标签模块Controller层实现
- `src/modules/system/tag/tag.test.md` - 标签模块测试用例文档
- `src/modules/system/log/log.schema.ts` - 日志模块Schema定义
- `src/modules/system/log/log.response.ts` - 日志模块响应格式定义
- `src/modules/system/log/log.service.ts` - 日志模块Service层实现
- `src/modules/system/log/log.controller.ts` - 日志模块Controller层实现
- `src/modules/system/log/log.test.md` - 日志模块测试用例文档
### 备注 (Notes)
- 验证码功能已有captcha模块可直接集成
- 遵循Elysia开发规范每个接口都要有完整的5个文件
- 按照PRD优先级P0 > P1 > P2 顺序开发
## 任务 (Tasks)
### 🔐 认证模块 (Auth Module) - P0优先级
- [x] 1.0 POST /auth/register - 用户注册接口
- [x] 1.1 创建auth.schema.ts - 定义用户注册Schema
- [x] 1.2 创建auth.response.ts - 定义注册响应格式
- [x] 1.3 创建auth.service.ts - 实现注册业务逻辑
- [x] 1.4 创建auth.controller.ts - 实现注册路由
- [x] 1.5 创建auth.test.md - 编写注册测试用例文档
- [x] 2.0 POST /auth/activate - 邮箱激活接口
- [x] 2.1 扩展auth.schema.ts - 定义激活Schema
- [x] 2.2 扩展auth.response.ts - 定义激活响应格式
- [x] 2.3 扩展auth.service.ts - 实现激活业务逻辑
- [x] 2.4 扩展auth.controller.ts - 实现激活路由
- [x] 2.5 扩展auth.test.md - 编写激活测试用例文档
- [x] 3.0 POST /auth/login - 用户登录接口
- [x] 3.1 扩展auth.schema.ts - 定义登录Schema
- [x] 3.2 扩展auth.response.ts - 定义登录响应格式
- [x] 3.3 扩展auth.service.ts - 实现登录业务逻辑
- [x] 3.4 扩展auth.controller.ts - 实现登录路由
- [x] 3.5 扩展auth.test.md - 编写登录测试用例文档
- [x] 4.0 POST /auth/refresh - Token刷新接口
- [x] 4.1 扩展auth.schema.ts - 定义刷新Schema
- [x] 4.2 扩展auth.response.ts - 定义刷新响应格式
- [x] 4.3 扩展auth.service.ts - 实现刷新业务逻辑
- [x] 4.4 扩展auth.controller.ts - 实现刷新路由
- [x] 4.5 扩展auth.test.md - 编写刷新测试用例文档
- [ ] 5.0 POST /auth/logout - 退出登录接口
- [ ] 5.1 扩展auth.schema.ts - 定义退出Schema
- [ ] 5.2 扩展auth.response.ts - 定义退出响应格式
- [ ] 5.3 扩展auth.service.ts - 实现退出业务逻辑
- [ ] 5.4 扩展auth.controller.ts - 实现退出路由
- [ ] 5.5 扩展auth.test.md - 编写退出测试用例文档
- [ ] 6.0 POST /auth/password/reset-request - 找回密码接口
- [ ] 6.1 扩展auth.schema.ts - 定义找回密码Schema
- [ ] 6.2 扩展auth.response.ts - 定义找回密码响应格式
- [ ] 6.3 扩展auth.service.ts - 实现找回密码业务逻辑
- [ ] 6.4 扩展auth.controller.ts - 实现找回密码路由
- [ ] 6.5 扩展auth.test.md - 编写找回密码测试用例文档
- [ ] 7.0 POST /auth/password/reset-confirm - 重置密码接口
- [ ] 7.1 扩展auth.schema.ts - 定义重置密码Schema
- [ ] 7.2 扩展auth.response.ts - 定义重置密码响应格式
- [ ] 7.3 扩展auth.service.ts - 实现重置密码业务逻辑
- [ ] 7.4 扩展auth.controller.ts - 实现重置密码路由
- [ ] 7.5 扩展auth.test.md - 编写重置密码测试用例文档
- [x] 8.0 GET /auth/captcha - 图形验证码接口
- [x] 8.1 扩展auth.schema.ts - 定义验证码Schema
- [x] 8.2 扩展auth.response.ts - 定义验证码响应格式
- [x] 8.3 扩展auth.service.ts - 集成验证码服务
- [x] 8.4 扩展auth.controller.ts - 实现验证码路由
- [x] 8.5 扩展auth.test.md - 编写验证码测试用例文档
- [ ] 9.0 检查认证模块 (Auth Module)那些接口需要加分布式锁,并加锁
### 👤 用户管理模块 (User Module) - P0优先级
- [ ] 9.0 GET /users/me - 获取当前用户信息接口
- [ ] 9.1 扩展user.schema.ts - 定义当前用户Schema
- [ ] 9.2 扩展user.response.ts - 定义当前用户响应格式
- [ ] 9.3 扩展user.service.ts - 实现当前用户业务逻辑
- [ ] 9.4 更新user.controller.ts - 实现当前用户路由
- [ ] 9.5 创建user.test.md - 编写当前用户测试用例文档
- [ ] 10.0 GET /users - 用户列表查询接口
- [ ] 10.1 扩展user.schema.ts - 定义用户列表Schema
- [ ] 10.2 扩展user.response.ts - 定义用户列表响应格式
- [ ] 10.3 扩展user.service.ts - 实现用户列表业务逻辑
- [ ] 10.4 扩展user.controller.ts - 实现用户列表路由
- [ ] 10.5 扩展user.test.md - 编写用户列表测试用例文档
- [ ] 11.0 POST /users - 创建用户接口
- [ ] 11.1 扩展user.schema.ts - 定义创建用户Schema
- [ ] 11.2 扩展user.response.ts - 定义创建用户响应格式
- [ ] 11.3 扩展user.service.ts - 实现创建用户业务逻辑
- [ ] 11.4 扩展user.controller.ts - 实现创建用户路由
- [ ] 11.5 扩展user.test.md - 编写创建用户测试用例文档
- [ ] 12.0 PUT /users/{id} - 更新用户信息接口
- [ ] 12.1 扩展user.schema.ts - 定义更新用户Schema
- [ ] 12.2 扩展user.response.ts - 定义更新用户响应格式
- [ ] 12.3 扩展user.service.ts - 实现更新用户业务逻辑
- [ ] 12.4 扩展user.controller.ts - 实现更新用户路由
- [ ] 12.5 扩展user.test.md - 编写更新用户测试用例文档
- [ ] 13.0 DELETE /users/{id} - 删除用户接口
- [ ] 13.1 扩展user.schema.ts - 定义删除用户Schema
- [ ] 13.2 扩展user.response.ts - 定义删除用户响应格式
- [ ] 13.3 扩展user.service.ts - 实现删除用户业务逻辑
- [ ] 13.4 扩展user.controller.ts - 实现删除用户路由
- [ ] 13.5 扩展user.test.md - 编写删除用户测试用例文档
- [ ] 14.0 PUT /users/me/password - 修改密码接口
- [ ] 14.1 扩展user.schema.ts - 定义修改密码Schema
- [ ] 14.2 扩展user.response.ts - 定义修改密码响应格式
- [ ] 14.3 扩展user.service.ts - 实现修改密码业务逻辑
- [ ] 14.4 扩展user.controller.ts - 实现修改密码路由
- [ ] 14.5 扩展user.test.md - 编写修改密码测试用例文档
- [ ] 15.0 GET /users/{id} - 用户详情接口
- [ ] 15.1 扩展user.schema.ts - 定义用户详情Schema
- [ ] 15.2 扩展user.response.ts - 定义用户详情响应格式
- [ ] 15.3 扩展user.service.ts - 实现用户详情业务逻辑
- [ ] 15.4 扩展user.controller.ts - 实现用户详情路由
- [ ] 15.5 扩展user.test.md - 编写用户详情测试用例文档
- [ ] 16.0 POST /users/batch - 批量操作接口
- [ ] 16.1 扩展user.schema.ts - 定义批量操作Schema
- [ ] 16.2 扩展user.response.ts - 定义批量操作响应格式
- [ ] 16.3 扩展user.service.ts - 实现批量操作业务逻辑
- [ ] 16.4 扩展user.controller.ts - 实现批量操作路由
- [ ] 16.5 扩展user.test.md - 编写批量操作测试用例文档
### 🎭 角色权限模块 (Role Module) - P0优先级
- [ ] 17.0 GET /roles - 角色列表接口
- [ ] 17.1 创建role.schema.ts - 定义角色Schema
- [ ] 17.2 创建role.response.ts - 定义角色响应格式
- [ ] 17.3 创建role.service.ts - 实现角色业务逻辑
- [ ] 17.4 创建role.controller.ts - 实现角色路由
- [ ] 17.5 创建role.test.md - 编写角色测试用例文档
- [ ] 18.0 POST /roles - 创建角色接口
- [ ] 18.1 扩展role.schema.ts - 定义创建角色Schema
- [ ] 18.2 扩展role.response.ts - 定义创建角色响应格式
- [ ] 18.3 扩展role.service.ts - 实现创建角色业务逻辑
- [ ] 18.4 扩展role.controller.ts - 实现创建角色路由
- [ ] 18.5 扩展role.test.md - 编写创建角色测试用例文档
- [ ] 19.0 PUT /roles/{id} - 更新角色接口
- [ ] 19.1 扩展role.schema.ts - 定义更新角色Schema
- [ ] 19.2 扩展role.response.ts - 定义更新角色响应格式
- [ ] 19.3 扩展role.service.ts - 实现更新角色业务逻辑
- [ ] 19.4 扩展role.controller.ts - 实现更新角色路由
- [ ] 19.5 扩展role.test.md - 编写更新角色测试用例文档
- [ ] 20.0 DELETE /roles/{id} - 删除角色接口
- [ ] 20.1 扩展role.schema.ts - 定义删除角色Schema
- [ ] 20.2 扩展role.response.ts - 定义删除角色响应格式
- [ ] 20.3 扩展role.service.ts - 实现删除角色业务逻辑
- [ ] 20.4 扩展role.controller.ts - 实现删除角色路由
- [ ] 20.5 扩展role.test.md - 编写删除角色测试用例文档
- [ ] 21.0 GET /permissions - 权限列表接口
- [ ] 21.1 创建permission.schema.ts - 定义权限Schema
- [ ] 21.2 创建permission.response.ts - 定义权限响应格式
- [ ] 21.3 创建permission.service.ts - 实现权限业务逻辑
- [ ] 21.4 创建permission.controller.ts - 实现权限路由
- [ ] 21.5 创建permission.test.md - 编写权限测试用例文档
- [ ] 22.0 POST /roles/{id}/permissions - 权限分配接口
- [ ] 22.1 扩展role.schema.ts - 定义权限分配Schema
- [ ] 22.2 扩展role.response.ts - 定义权限分配响应格式
- [ ] 22.3 扩展role.service.ts - 实现权限分配业务逻辑
- [ ] 22.4 扩展role.controller.ts - 实现权限分配路由
- [ ] 22.5 扩展role.test.md - 编写权限分配测试用例文档
- [ ] 23.0 POST /users/{id}/roles - 用户角色分配接口
- [ ] 23.1 扩展user.schema.ts - 定义用户角色分配Schema
- [ ] 23.2 扩展user.response.ts - 定义用户角色分配响应格式
- [ ] 23.3 扩展user.service.ts - 实现用户角色分配业务逻辑
- [ ] 23.4 扩展user.controller.ts - 实现用户角色分配路由
- [ ] 23.5 扩展user.test.md - 编写用户角色分配测试用例文档
### 🏢 组织架构模块 (Organization Module) - P1优先级
- [ ] 24.0 GET /organizations - 组织列表接口
- [ ] 24.1 创建organization.schema.ts - 定义组织Schema
- [ ] 24.2 创建organization.response.ts - 定义组织响应格式
- [ ] 24.3 创建organization.service.ts - 实现组织业务逻辑
- [ ] 24.4 创建organization.controller.ts - 实现组织路由
- [ ] 24.5 创建organization.test.md - 编写组织测试用例文档
- [ ] 25.0 POST /organizations - 创建组织接口
- [ ] 25.1 扩展organization.schema.ts - 定义创建组织Schema
- [ ] 25.2 扩展organization.response.ts - 定义创建组织响应格式
- [ ] 25.3 扩展organization.service.ts - 实现创建组织业务逻辑
- [ ] 25.4 扩展organization.controller.ts - 实现创建组织路由
- [ ] 25.5 扩展organization.test.md - 编写创建组织测试用例文档
- [ ] 26.0 PUT /organizations/{id} - 更新组织接口
- [ ] 26.1 扩展organization.schema.ts - 定义更新组织Schema
- [ ] 26.2 扩展organization.response.ts - 定义更新组织响应格式
- [ ] 26.3 扩展organization.service.ts - 实现更新组织业务逻辑
- [ ] 26.4 扩展organization.controller.ts - 实现更新组织路由
- [ ] 26.5 扩展organization.test.md - 编写更新组织测试用例文档
- [ ] 27.0 DELETE /organizations/{id} - 删除组织接口
- [ ] 27.1 扩展organization.schema.ts - 定义删除组织Schema
- [ ] 27.2 扩展organization.response.ts - 定义删除组织响应格式
- [ ] 27.3 扩展organization.service.ts - 实现删除组织业务逻辑
- [ ] 27.4 扩展organization.controller.ts - 实现删除组织路由
- [ ] 27.5 扩展organization.test.md - 编写删除组织测试用例文档
- [ ] 28.0 POST /users/{id}/organizations - 用户组织关系接口
- [ ] 28.1 扩展user.schema.ts - 定义用户组织关系Schema
- [ ] 28.2 扩展user.response.ts - 定义用户组织关系响应格式
- [ ] 28.3 扩展user.service.ts - 实现用户组织关系业务逻辑
- [ ] 28.4 扩展user.controller.ts - 实现用户组织关系路由
- [ ] 28.5 扩展user.test.md - 编写用户组织关系测试用例文档
### 🗂️ 系统基础模块 (System Module) - P1优先级
- [ ] 29.0 字典类型管理 - CRUD /dict-types
- [ ] 29.1 创建dict.schema.ts - 定义字典类型Schema
- [ ] 29.2 创建dict.response.ts - 定义字典类型响应格式
- [ ] 29.3 创建dict.service.ts - 实现字典类型业务逻辑
- [ ] 29.4 创建dict.controller.ts - 实现字典类型路由
- [ ] 29.5 创建dict.test.md - 编写字典类型测试用例文档
- [ ] 30.0 字典项管理 - CRUD /dict-items
- [ ] 30.1 扩展dict.schema.ts - 定义字典项Schema
- [ ] 30.2 扩展dict.response.ts - 定义字典项响应格式
- [ ] 30.3 扩展dict.service.ts - 实现字典项业务逻辑
- [ ] 30.4 扩展dict.controller.ts - 实现字典项路由
- [ ] 30.5 扩展dict.test.md - 编写字典项测试用例文档
- [ ] 31.0 标签管理 - CRUD /tags
- [ ] 31.1 创建tag.schema.ts - 定义标签Schema
- [ ] 31.2 创建tag.response.ts - 定义标签响应格式
- [ ] 31.3 创建tag.service.ts - 实现标签业务逻辑
- [ ] 31.4 创建tag.controller.ts - 实现标签路由
- [ ] 31.5 创建tag.test.md - 编写标签测试用例文档
- [ ] 32.0 操作日志 - GET /logs/operations
- [ ] 32.1 创建log.schema.ts - 定义操作日志Schema
- [ ] 32.2 创建log.response.ts - 定义操作日志响应格式
- [ ] 32.3 创建log.service.ts - 实现操作日志业务逻辑
- [ ] 32.4 创建log.controller.ts - 实现操作日志路由
- [ ] 32.5 创建log.test.md - 编写操作日志测试用例文档
- [ ] 33.0 登录日志 - GET /logs/logins
- [ ] 33.1 扩展log.schema.ts - 定义登录日志Schema
- [ ] 33.2 扩展log.response.ts - 定义登录日志响应格式
- [ ] 33.3 扩展log.service.ts - 实现登录日志业务逻辑
- [ ] 33.4 扩展log.controller.ts - 实现登录日志路由
- [ ] 33.5 扩展log.test.md - 编写登录日志测试用例文档
### 🔧 基础设施完善
- [ ] 34.0 JWT认证中间件
- [ ] 34.1 创建JWT认证插件
- [ ] 34.2 实现Token黑名单管理
- [ ] 34.3 实现RefreshToken机制
- [ ] 34.4 集成权限验证中间件
- [ ] 34.5 编写认证中间件测试
- [ ] 35.0 路由模块集成
- [ ] 35.1 更新src/modules/index.ts - 集成所有模块
- [ ] 35.2 更新src/app.ts - 注册所有路由
- [ ] 35.3 更新Swagger标签定义
- [ ] 35.4 完善API文档
- [ ] 35.5 集成测试验证
## 开发优先级说明
### 第一阶段P0基础认证和用户管理
- **认证模块**用户注册、激活、登录、刷新、退出任务1-5
- **用户管理模块**当前用户、用户列表、用户CRUD、密码管理任务9-14
- **完成目标**:具备基本的用户认证和管理功能
### 第二阶段P0角色权限系统
- **角色管理**角色CRUD、权限分配任务17-20
- **权限管理**权限列表、权限分配、用户角色分配任务21-23
- **完成目标**具备完整的RBAC权限控制体系
### 第三阶段P1扩展功能
- **密码管理**找回密码、重置密码任务6-7
- **验证码系统**图形验证码任务8
- **用户扩展**用户详情、批量操作任务15-16
- **组织架构**组织管理、用户组织关系任务24-28
### 第四阶段P1-P2系统完善
- **系统基础**字典、标签、日志管理任务29-33
- **基础设施**JWT中间件、路由集成任务34-35
- **完成目标**:系统功能完整,可投入生产使用
## 备注说明
1. **已完成部分**用户模块的Schema、Response、Service已基本完成可直接使用
2. **验证码集成**现有captcha模块可直接集成到认证流程中
3. **开发规范**严格按照Elysia开发规范每个接口都要有完整的5个子任务
4. **测试要求**:每个模块都要有完整的测试用例文档,确保功能正确性
5. **优先级管理**按照P0 > P1 > P2的顺序开发确保核心功能优先完成