feat: 新增目标子任务管理功能模块
- 实现目标子任务的完整功能,包括数据库表设计、API接口、业务逻辑和文档说明。 - 支持用户创建、管理和跟踪目标子任务,提供增删改查操作及任务完成记录功能。 - 引入惰性任务生成机制,优化任务管理体验,提升系统性能和用户交互。
This commit is contained in:
185
test-goal-tasks.http
Normal file
185
test-goal-tasks.http
Normal file
@@ -0,0 +1,185 @@
|
||||
### 目标子任务API测试文件
|
||||
|
||||
@baseUrl = http://localhost:3000
|
||||
@token = your-auth-token-here
|
||||
|
||||
### 1. 创建每日喝水目标
|
||||
POST {{baseUrl}}/goals
|
||||
Authorization: Bearer {{token}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"title": "每日喝水",
|
||||
"description": "每天喝8杯水保持健康",
|
||||
"repeatType": "daily",
|
||||
"frequency": 8,
|
||||
"category": "健康",
|
||||
"startDate": "2024-01-01",
|
||||
"hasReminder": true,
|
||||
"reminderTime": "09:00"
|
||||
}
|
||||
|
||||
### 2. 创建每周运动目标
|
||||
POST {{baseUrl}}/goals
|
||||
Authorization: Bearer {{token}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"title": "每周运动",
|
||||
"description": "每周运动3次,每次至少30分钟",
|
||||
"repeatType": "weekly",
|
||||
"frequency": 3,
|
||||
"category": "运动",
|
||||
"startDate": "2024-01-01",
|
||||
"targetCount": 52
|
||||
}
|
||||
|
||||
### 3. 创建自定义周期目标(周末阅读)
|
||||
POST {{baseUrl}}/goals
|
||||
Authorization: Bearer {{token}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"title": "周末阅读",
|
||||
"description": "每个周末阅读1小时",
|
||||
"repeatType": "custom",
|
||||
"frequency": 1,
|
||||
"customRepeatRule": {
|
||||
"weekdays": [0, 6]
|
||||
},
|
||||
"category": "学习",
|
||||
"startDate": "2024-01-01"
|
||||
}
|
||||
|
||||
### 4. 获取目标列表(触发任务生成)
|
||||
GET {{baseUrl}}/goals?page=1&pageSize=10
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 5. 获取所有任务列表
|
||||
GET {{baseUrl}}/goals/tasks?page=1&pageSize=20
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 6. 获取今天的任务
|
||||
GET {{baseUrl}}/goals/tasks?startDate=2024-01-15&endDate=2024-01-15
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 7. 获取进行中的任务
|
||||
GET {{baseUrl}}/goals/tasks?status=pending
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 8. 获取特定目标的任务列表
|
||||
# 需要替换为实际的goalId
|
||||
GET {{baseUrl}}/goals/{goalId}/tasks
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 9. 完成任务 - 单次完成
|
||||
# 需要替换为实际的taskId
|
||||
POST {{baseUrl}}/goals/tasks/{taskId}/complete
|
||||
Authorization: Bearer {{token}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"count": 1,
|
||||
"notes": "早上喝了第一杯水"
|
||||
}
|
||||
|
||||
### 10. 完成任务 - 多次完成
|
||||
# 需要替换为实际的taskId
|
||||
POST {{baseUrl}}/goals/tasks/{taskId}/complete
|
||||
Authorization: Bearer {{token}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"count": 3,
|
||||
"notes": "连续喝了3杯水",
|
||||
"completedAt": "2024-01-15T14:30:00Z"
|
||||
}
|
||||
|
||||
### 11. 获取单个任务详情
|
||||
# 需要替换为实际的taskId
|
||||
GET {{baseUrl}}/goals/tasks/{taskId}
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 12. 更新任务
|
||||
# 需要替换为实际的taskId
|
||||
PUT {{baseUrl}}/goals/tasks/{taskId}
|
||||
Authorization: Bearer {{token}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"notes": "修改了任务备注",
|
||||
"targetCount": 10
|
||||
}
|
||||
|
||||
### 13. 跳过任务
|
||||
# 需要替换为实际的taskId
|
||||
POST {{baseUrl}}/goals/tasks/{taskId}/skip
|
||||
Authorization: Bearer {{token}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"reason": "今天身体不舒服,暂时跳过"
|
||||
}
|
||||
|
||||
### 14. 获取任务统计(所有目标)
|
||||
GET {{baseUrl}}/goals/tasks/stats/overview
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 15. 获取特定目标的任务统计
|
||||
# 需要替换为实际的goalId
|
||||
GET {{baseUrl}}/goals/tasks/stats/overview?goalId={goalId}
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 16. 获取目标详情(包含任务)
|
||||
# 需要替换为实际的goalId
|
||||
GET {{baseUrl}}/goals/{goalId}
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 17. 批量操作目标
|
||||
POST {{baseUrl}}/goals/batch
|
||||
Authorization: Bearer {{token}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"goalIds": ["goal-id-1", "goal-id-2"],
|
||||
"action": "pause"
|
||||
}
|
||||
|
||||
### 18. 获取过期任务
|
||||
GET {{baseUrl}}/goals/tasks?status=overdue
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 19. 获取已完成任务
|
||||
GET {{baseUrl}}/goals/tasks?status=completed&page=1&pageSize=10
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 20. 获取本周任务
|
||||
GET {{baseUrl}}/goals/tasks?startDate=2024-01-08&endDate=2024-01-14
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 测试场景说明
|
||||
|
||||
# 场景1:每日喝水目标测试流程
|
||||
# 1. 创建每日喝水目标(接口1)
|
||||
# 2. 获取目标列表触发任务生成(接口4)
|
||||
# 3. 查看今天的任务(接口6)
|
||||
# 4. 分多次完成喝水任务(接口9、10)
|
||||
# 5. 查看任务统计(接口14)
|
||||
|
||||
# 场景2:每周运动目标测试流程
|
||||
# 1. 创建每周运动目标(接口2)
|
||||
# 2. 获取本周任务(接口20)
|
||||
# 3. 完成运动任务(接口9)
|
||||
# 4. 查看特定目标的任务列表(接口8)
|
||||
|
||||
# 场景3:任务管理测试流程
|
||||
# 1. 查看所有待完成任务(接口7)
|
||||
# 2. 跳过某个任务(接口13)
|
||||
# 3. 更新任务信息(接口12)
|
||||
# 4. 查看过期任务(接口18)
|
||||
|
||||
### 注意事项
|
||||
# 1. 替换所有的 {goalId} 和 {taskId} 为实际的ID值
|
||||
# 2. 替换 {{token}} 为有效的认证令牌
|
||||
# 3. 根据实际情况调整日期参数
|
||||
# 4. 某些API需要先创建目标和任务后才能测试
|
||||
Reference in New Issue
Block a user