Version: 0.3.2.dev.260214

feat:  新增获取当前正在进行的任务接口并完成测试

- 若当前为上课时间,返回当前任务 📚
- 若当前为下课/空闲时间,返回下一个任务 ➡️
- 若存在嵌入任务,支持嵌套返回结构 🧩
- 接口已测试通过 🧪

docs: 📝 小幅更新 README

fix: 🐛 修复获取最近已完成任务列表接口的遗漏问题

- 修复无法获取嵌入在课程中的任务问题 🔧

fix: 🐛 修复删除日程接口的字段遗漏问题

- 若删除的是单独任务块,补充删除 task_item 表的 embedded_time 字段
- 避免数据残留与状态异常 
This commit is contained in:
LoveLosita
2026-02-14 21:46:02 +08:00
parent 63500b3b2a
commit dad1eade93
11 changed files with 347 additions and 48 deletions

View File

@@ -106,3 +106,40 @@ func (s *ScheduleAPI) GetUserRecentCompletedSchedules(c *gin.Context) {
//3.返回数据给前端
c.JSON(http.StatusOK, respond.RespWithData(respond.Ok, completedSchedules))
}
func (s *ScheduleAPI) GetUserOngoingSchedule(c *gin.Context) {
// 1. 从请求上下文中获取用户ID
userID := c.GetInt("user_id")
//2.调用服务层方法获取用户正在进行的日程事件
ctx, cancel := context.WithTimeout(c.Request.Context(), 1*time.Second)
defer cancel() // 记得释放资源
ongoingSchedule, err := s.scheduleService.GetUserOngoingSchedule(ctx, userID)
if err != nil {
respond.DealWithError(c, err)
return
}
//3.返回数据给前端
c.JSON(http.StatusOK, respond.RespWithData(respond.Ok, ongoingSchedule))
}
func (s *ScheduleAPI) UserRevocateTaskItemFromSchedule(c *gin.Context) {
// 1. 从请求上下文中获取用户ID
userID := c.GetInt("user_id")
// 2. 获取要撤销的任务块ID
eventID := c.Query("event_id")
intEventID, err := strconv.Atoi(eventID)
if err != nil {
c.JSON(http.StatusBadRequest, respond.WrongParamType)
return
}
//3.调用服务层方法撤销任务块的安排
/*ctx, cancel := context.WithTimeout(c.Request.Context(), 1*time.Second)
defer cancel() // 记得释放资源*/
err = s.scheduleService.RevocateUserTaskClassItem(context.Background(), userID, intEventID)
if err != nil {
respond.DealWithError(c, err)
return
}
//4.返回撤销成功的响应给前端
c.JSON(http.StatusOK, respond.Ok)
}