269 lines
11 KiB
Markdown
269 lines
11 KiB
Markdown
# Implementation Plan: 小程序API开发
|
||
|
||
## Overview
|
||
|
||
本任务清单将小程序API开发分为8个模块,按P0→P1→P2优先级顺序实现。每个模块包含实体类、DTO、服务接口、服务实现、控制器的开发任务。
|
||
|
||
## Tasks
|
||
|
||
- [x] 1. 项目基础设施搭建
|
||
- [x] 1.1 创建新增实体类文件
|
||
- 在 `MiAssessment.Model/Entities/` 目录创建 Banner.cs, Promotion.cs, BusinessPage.cs, Planner.cs, PlannerBooking.cs, InviteCode.cs, Commission.cs, Withdrawal.cs
|
||
- 配置 `[Table]` 特性映射到数据库表
|
||
- _Requirements: 1.1, 2.1, 10.1, 11.1, 13.1_
|
||
|
||
- [x] 1.2 创建DTO模型文件
|
||
- 在 `MiAssessment.Model/Models/` 目录按模块创建子目录和DTO类
|
||
- 包含 Home/, Business/, Assessment/, Order/, Planner/, Invite/, System/, Team/ 目录
|
||
- _Requirements: 16.1, 16.4_
|
||
|
||
- [x] 1.3 更新DbContext注册实体
|
||
- 在 ApiDbContext 中添加新实体的 DbSet 属性
|
||
- _Requirements: 1.1, 2.1, 10.1, 11.1_
|
||
|
||
- [x] 2. 首页模块 (P0)
|
||
- [x] 2.1 创建 IHomeService 接口
|
||
- 定义 GetBannerListAsync, GetAssessmentListAsync, GetPromotionListAsync 方法
|
||
- _Requirements: 1.1, 1.2, 1.3_
|
||
|
||
- [x] 2.2 实现 HomeService 服务
|
||
- 实现Banner列表查询,过滤Status=1且未删除,按Sort降序
|
||
- 实现测评类型列表查询,过滤未删除记录
|
||
- 实现宣传图列表查询,过滤Position=1且Status=1
|
||
- _Requirements: 1.1, 1.2, 1.3_
|
||
|
||
- [x] 2.3 编写 HomeService 属性测试
|
||
- **Property 1: 列表查询过滤正确性**
|
||
- **Validates: Requirements 1.1, 1.2, 1.3**
|
||
|
||
- [x] 2.4 创建 HomeController 控制器
|
||
- 实现 GET /api/home/getBannerList
|
||
- 实现 GET /api/home/getAssessmentList
|
||
- 实现 GET /api/home/getPromotionList
|
||
- 所有接口不需要 [Authorize] 特性
|
||
- _Requirements: 1.1, 1.2, 1.3, 1.4_
|
||
|
||
- [x] 2.5 注册首页模块依赖注入
|
||
- 在 Program.cs 中注册 IHomeService 和 HomeService
|
||
- _Requirements: 1.1_
|
||
|
||
- [x] 3. Checkpoint - 首页模块验证
|
||
- 确保首页模块所有接口可正常调用,返回格式正确
|
||
- 确保所有测试通过,如有问题请询问用户
|
||
|
||
- [x] 4. 测评模块 (P0)
|
||
- [x] 4.1 创建 IAssessmentService 接口
|
||
- 定义测评介绍、题目列表、答案提交、结果查询、邀请码验证、往期测评等方法
|
||
- _Requirements: 3.1, 3.2, 4.1, 4.2, 4.3, 5.1, 6.1_
|
||
|
||
- [x] 4.2 实现 AssessmentService - 查询功能
|
||
- 实现 GetIntroAsync: 根据typeId查询测评介绍
|
||
- 实现 GetQuestionListAsync: 根据typeId查询启用题目,按QuestionNo排序
|
||
- 实现 GetResultStatusAsync: 查询测评记录状态
|
||
- 实现 GetHistoryListAsync: 分页查询用户测评记录
|
||
- _Requirements: 3.1, 3.2, 4.2, 6.1, 6.2_
|
||
|
||
- [x] 4.3 编写测评查询属性测试
|
||
- **Property 2: 列表查询排序正确性**
|
||
- **Property 3: 分页查询一致性**
|
||
- **Validates: Requirements 3.2, 6.1**
|
||
|
||
- [x] 4.4 实现 AssessmentService - 邀请码验证
|
||
- 实现 VerifyInviteCodeAsync: 验证邀请码存在性和使用状态
|
||
- 返回正确的错误信息(不存在/已使用)
|
||
- _Requirements: 5.1, 5.2, 5.3, 5.4_
|
||
|
||
- [x] 4.5 编写邀请码验证属性测试
|
||
- **Property 6: 邀请码使用一次性**
|
||
- **Validates: Requirements 5.1, 5.3, 5.4**
|
||
|
||
- [x] 4.6 实现 AssessmentService - 答案提交
|
||
- 实现 SubmitAnswersAsync: 验证记录归属,保存答案,更新状态
|
||
- 验证答案数量与题目数量匹配
|
||
- _Requirements: 4.1, 4.4_
|
||
|
||
- [x] 4.7 编写答案提交属性测试
|
||
- **Property 9: 测评答案提交状态变更**
|
||
- **Validates: Requirements 4.1, 4.2**
|
||
|
||
- [x] 4.8 实现 AssessmentService - 结果查询
|
||
- 实现 GetResultAsync: 验证记录归属和完成状态,组装报告数据
|
||
- 组装八大智能、个人特质、细分能力等多层嵌套数据
|
||
- _Requirements: 4.3, 4.5_
|
||
|
||
- [x] 4.9 编写结果查询属性测试
|
||
- **Property 4: 用户数据隔离**
|
||
- **Validates: Requirements 4.3, 4.5**
|
||
|
||
- [x] 4.10 创建 AssessmentController 控制器
|
||
- 实现所有7个测评接口
|
||
- getIntro 不需要认证,其他接口需要 [Authorize]
|
||
- _Requirements: 3.1, 3.2, 3.3, 4.1, 4.2, 4.3, 5.1, 6.1_
|
||
|
||
- [x] 4.11 注册测评模块依赖注入
|
||
- _Requirements: 3.1_
|
||
|
||
- [x] 5. Checkpoint - 测评模块验证
|
||
- 确保测评模块所有接口可正常调用
|
||
- 确保认证逻辑正确(getIntro无需认证,其他需要)
|
||
- 确保所有测试通过,如有问题请询问用户
|
||
|
||
- [x] 6. 订单模块 (P0)
|
||
- [x] 6.1 创建 IOrderService 接口
|
||
- 定义订单列表、详情、创建、支付、支付结果查询方法
|
||
- _Requirements: 7.1, 7.2, 8.1, 9.1, 9.2_
|
||
|
||
- [x] 6.2 实现 OrderService - 查询功能
|
||
- 实现 GetListAsync: 分页查询用户订单,支持类型筛选
|
||
- 实现 GetDetailAsync: 查询订单详情,关联测评记录或规划预约
|
||
- 实现 GetPayResultAsync: 查询订单支付状态
|
||
- _Requirements: 7.1, 7.2, 7.3, 9.2_
|
||
|
||
- [x] 6.3 编写订单查询属性测试
|
||
- **Property 3: 分页查询一致性**
|
||
- **Property 4: 用户数据隔离**
|
||
- **Validates: Requirements 7.1, 7.2, 7.3**
|
||
|
||
- [x] 6.4 实现 OrderService - 订单创建
|
||
- 实现 CreateAsync: 使用事务创建订单和关联记录
|
||
- 支持测评订单(创建assessment_record)和规划订单(创建planner_booking)
|
||
- 支持邀请码抵扣(金额设为0,标记邀请码已使用)
|
||
- _Requirements: 8.1, 8.2, 8.3, 8.4, 8.5_
|
||
|
||
- [x] 6.5 编写订单创建属性测试
|
||
- **Property 5: 订单创建完整性**
|
||
- **Property 10: 订单事务回滚**
|
||
- **Validates: Requirements 8.1, 8.2, 8.3, 8.4**
|
||
|
||
- [x] 6.6 实现 OrderService - 支付功能
|
||
- 实现 PayAsync: 调用已有的PayService发起微信支付
|
||
- 验证订单状态(待支付才能发起支付)
|
||
- _Requirements: 9.1, 9.3_
|
||
|
||
- [x] 6.7 创建 OrderController 控制器
|
||
- 实现所有5个订单接口,全部需要 [Authorize]
|
||
- _Requirements: 7.1, 7.2, 8.1, 9.1, 9.2_
|
||
|
||
- [x] 6.8 注册订单模块依赖注入
|
||
- _Requirements: 7.1_
|
||
|
||
- [x] 7. Checkpoint - P0核心模块验证
|
||
- 确保首页、测评、订单三个核心模块全部可用
|
||
- 验证完整的测评购买流程:首页→测评介绍→创建订单→支付→答题→查看结果
|
||
- 确保所有测试通过,如有问题请询问用户
|
||
|
||
- [x] 8. 业务详情模块 (P1)
|
||
- [x] 8.1 创建 IBusinessService 接口和 BusinessService 实现
|
||
- 实现 GetDetailAsync: 根据ID查询业务页面详情
|
||
- _Requirements: 2.1_
|
||
|
||
- [x] 8.2 创建 BusinessController 控制器
|
||
- 实现 GET /api/business/getDetail,不需要认证
|
||
- _Requirements: 2.1, 2.2_
|
||
|
||
- [x] 8.3 注册业务详情模块依赖注入
|
||
- _Requirements: 2.1_
|
||
|
||
- [x] 9. 规划师模块 (P1)
|
||
- [x] 9.1 创建 IPlannerService 接口和 PlannerService 实现
|
||
- 实现 GetListAsync: 查询启用的规划师,按Sort排序
|
||
- _Requirements: 10.1_
|
||
|
||
- [x] 9.2 编写规划师列表属性测试
|
||
- **Property 1: 列表查询过滤正确性**
|
||
- **Property 2: 列表查询排序正确性**
|
||
- **Validates: Requirements 10.1**
|
||
|
||
- [x] 9.3 创建 PlannerController 控制器
|
||
- 实现 GET /api/planner/getList,不需要认证
|
||
- _Requirements: 10.1, 10.2_
|
||
|
||
- [x] 9.4 注册规划师模块依赖注入
|
||
- _Requirements: 10.1_
|
||
|
||
- [x] 10. 分销模块 (P1)
|
||
- [x] 10.1 创建 IInviteService 接口
|
||
- 定义邀请信息、二维码、邀请记录、佣金、提现等方法
|
||
- _Requirements: 11.1, 11.2, 12.1, 12.2, 13.1, 13.5_
|
||
|
||
- [x] 10.2 实现 InviteService - 查询功能
|
||
- 实现 GetInfoAsync: 返回用户邀请码、余额、邀请人数
|
||
- 实现 GetQrcodeAsync: 调用微信小程序码接口生成二维码
|
||
- 实现 GetRecordListAsync: 分页查询直属下级用户
|
||
- 实现 GetCommissionAsync: 返回累计收益、已提现、待提现
|
||
- 实现 GetWithdrawListAsync: 分页查询提现记录
|
||
- _Requirements: 11.1, 11.2, 12.1, 12.2, 13.5_
|
||
|
||
- [x] 10.3 编写分销查询属性测试
|
||
- **Property 3: 分页查询一致性**
|
||
- **Validates: Requirements 12.1, 13.5**
|
||
|
||
- [x] 10.4 实现 InviteService - 提现功能
|
||
- 实现 ApplyWithdrawAsync: 验证余额,创建提现记录,扣减余额
|
||
- 验证提现金额≥1元且为整数
|
||
- 使用事务确保数据一致性
|
||
- _Requirements: 13.1, 13.2, 13.3, 13.4_
|
||
|
||
- [x] 10.5 编写提现属性测试
|
||
- **Property 7: 提现余额一致性**
|
||
- **Validates: Requirements 13.1**
|
||
|
||
- [x] 10.6 创建 InviteController 控制器
|
||
- 实现所有6个分销接口,全部需要 [Authorize]
|
||
- _Requirements: 11.1, 11.2, 11.3, 12.1, 12.2, 13.1, 13.5_
|
||
|
||
- [x] 10.7 注册分销模块依赖注入
|
||
- _Requirements: 11.1_
|
||
|
||
- [x] 11. Checkpoint - P1重要模块验证
|
||
- 确保业务详情、规划师、分销三个模块全部可用
|
||
- 验证分销流程:查看邀请信息→生成二维码→查看邀请记录→申请提现
|
||
- 确保所有测试通过,如有问题请询问用户
|
||
|
||
- [x] 12. 系统模块 (P2)
|
||
- [x] 12.1 创建 ISystemService 接口和 SystemService 实现
|
||
- 实现 GetAgreementAsync: 从configs表读取用户协议
|
||
- 实现 GetPrivacyAsync: 从configs表读取隐私政策
|
||
- 实现 GetAboutAsync: 从configs表读取关于我们和版本号
|
||
- _Requirements: 14.1, 14.2, 14.3_
|
||
|
||
- [x] 12.2 编写系统配置属性测试
|
||
- **Property 8: 响应格式一致性**
|
||
- **Validates: Requirements 14.1, 14.2, 14.3, 16.1, 16.2, 16.3**
|
||
|
||
- [x] 12.3 创建 SystemController 控制器
|
||
- 实现所有3个系统接口,不需要认证
|
||
- _Requirements: 14.1, 14.2, 14.3, 14.4_
|
||
|
||
- [x] 12.4 注册系统模块依赖注入
|
||
- _Requirements: 14.1_
|
||
|
||
- [x] 13. 团队模块 (P2)
|
||
- [x] 13.1 创建 ITeamService 接口和 TeamService 实现
|
||
- 实现 GetInfoAsync: 查询Position=2的宣传图列表
|
||
- _Requirements: 15.1_
|
||
|
||
- [x] 13.2 编写团队模块属性测试
|
||
- **Property 1: 列表查询过滤正确性**
|
||
- **Validates: Requirements 15.1**
|
||
|
||
- [x] 13.3 创建 TeamController 控制器
|
||
- 实现 GET /api/team/getInfo,不需要认证
|
||
- _Requirements: 15.1, 15.2_
|
||
|
||
- [x] 13.4 注册团队模块依赖注入
|
||
- _Requirements: 15.1_
|
||
|
||
- [x] 14. Final Checkpoint - 全部模块验证
|
||
- 确保所有28个API接口可正常调用
|
||
- 验证认证逻辑:需要认证的接口返回401,不需要认证的接口正常返回
|
||
- 验证响应格式统一性
|
||
- 确保所有测试通过,如有问题请询问用户
|
||
|
||
## Notes
|
||
|
||
- 开发顺序按P0→P1→P2优先级进行
|
||
- 每个模块完成后进行Checkpoint验证
|
||
- 属性测试使用FsCheck框架,每个测试运行100次迭代
|
||
- 所有接口遵循RPC风格,仅使用GET和POST请求
|