From 78f6276b1e727326b9797451db82cd6c7c480852 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期五, 25 八月 2023 11:45:00 +0800 Subject: [PATCH] 增加任务倒计时接口 --- api/v1/task.go | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/api/v1/task.go b/api/v1/task.go index 48484b3..23ae0a2 100644 --- a/api/v1/task.go +++ b/api/v1/task.go @@ -23,6 +23,28 @@ type TaskApi struct{} +// TaskCountdown +// @Tags Task +// @Summary 鏂颁换鍔″�掕鏃� +// @Produce application/json +// @Success 200 {object} contextx.Response{data=response.TaskCountdown} "鎴愬姛" +// @Router /v1/task/countdown [get] +func (slf *TaskApi) TaskCountdown(c *gin.Context) { + ctx, ok := contextx.NewContext(c, nil) + if !ok { + return + } + var resp response.TaskCountdown + workOrder, err := service.NewTaskService().GetComingTask() + if err == nil { + seconds := workOrder.StartTime - time.Now().Unix() + resp.CountDownHour = seconds / 3600 + resp.CountDownMinute = seconds % 3600 / 60 + resp.ShowCountDown = true + } + ctx.OkWithDetailed(resp) +} + // TaskGet // @Tags Task // @Summary 鑾峰彇浠诲姟 -- Gitblit v1.8.0