Version: 0.2.6.dev.260211

feat: 🕒 为 schedule_events 表新增 start_time 与 end_time 字段

- 新增 start_time 与 end_time 两列
- 支持最近已完成任务列表接口
- 为后续获取当前正在进行的任务接口做准备 🚧

feat:  新增最近已完成任务列表接口并通过测试

- 完成接口实现与测试 🧪
- 当前 sv 层使用测试时间进行逻辑验证
- ⚠️ 生产环境需改回使用当前时间
This commit is contained in:
LoveLosita
2026-02-11 21:08:50 +08:00
parent e5a4114202
commit 6dd1f656dc
6 changed files with 100 additions and 88 deletions

View File

@@ -79,3 +79,30 @@ func (s *ScheduleAPI) DeleteScheduleEvent(c *gin.Context) {
//4.返回删除成功的响应给前端
c.JSON(http.StatusOK, respond.Ok)
}
func (s *ScheduleAPI) GetUserRecentCompletedSchedules(c *gin.Context) {
// 1. 从请求上下文中获取用户ID以及其他查询参数如 index 和 limit
userID := c.GetInt("user_id")
index := c.Query("index")
limit := c.Query("limit")
intIndex, err := strconv.Atoi(index)
if err != nil {
c.JSON(http.StatusBadRequest, respond.WrongParamType)
return
}
intLimit, err := strconv.Atoi(limit)
if err != nil {
c.JSON(http.StatusBadRequest, respond.WrongParamType)
return
}
//2.调用服务层方法获取用户最近完成的日程事件
ctx, cancel := context.WithTimeout(c.Request.Context(), 1*time.Second)
defer cancel() // 记得释放资源
completedSchedules, err := s.scheduleService.GetUserRecentCompletedSchedules(ctx, userID, intIndex, intLimit)
if err != nil {
respond.DealWithError(c, err)
return
}
//3.返回数据给前端
c.JSON(http.StatusOK, respond.RespWithData(respond.Ok, completedSchedules))
}