From 61c0aaa35a3143a198cadb1ec1c5c9d67b6f7162 Mon Sep 17 00:00:00 2001 From: Echo <1711788888@qq.com> Date: Thu, 9 May 2024 18:06:45 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E4=BC=98=E5=8C=96=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=BD=93=E6=97=A5=E6=8F=90=E9=86=92=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/v1/app/todos.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) 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) }