diff --git a/api/v1/app/todos.go b/api/v1/app/todos.go index c96e156..79ac7c5 100644 --- a/api/v1/app/todos.go +++ b/api/v1/app/todos.go @@ -10,6 +10,7 @@ import ( "miniapp/model/common/request" r "miniapp/model/common/response" "strconv" + "time" ) type TodosApi struct{} @@ -79,5 +80,27 @@ func (t TodosApi) GetTodayTodos(ctx *gin.Context) { return } - r.OkWithData(list, ctx) + todos := make([]common.UserTodo, 0) + hour := time.Now().Hour() + for i := range list { + //将remind_time截取前两位 转为int + rt, _ := strconv.Atoi(list[i].RemindTime[:2]) + rt2 := 24 + + if i+1 == len(list) { + rt2, _ = strconv.Atoi(list[len(list)-1].RemindTime[:2]) + } else { + rt2, _ = strconv.Atoi(list[i+1].RemindTime[:2]) + } + if hour >= rt && hour <= rt2 { + todos = append(todos, list[i]) + } + } + + //删除todos第一个元素 + if len(todos) > 0 { + todos = todos[1:] + } + + r.OkWithData(todos, ctx) }