From 2d6875c93b25d0b7336c7fa11e066d213259fe2e Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期四, 25 四月 2024 10:02:01 +0800
Subject: [PATCH] 更改定时任务时区设置

---
 pkg/contextx/contextx.go |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/pkg/contextx/contextx.go b/pkg/contextx/contextx.go
index c4350a9..3c5b175 100644
--- a/pkg/contextx/contextx.go
+++ b/pkg/contextx/contextx.go
@@ -18,6 +18,12 @@
 		Data interface{} `json:"data"`
 		Msg  string      `json:"msg"`
 	}
+	ResponseList struct {
+		Code  int         `json:"code"`
+		Data  interface{} `json:"data"`
+		Msg   string      `json:"msg"`
+		Total int64       `json:"total"`
+	}
 )
 
 func NewContext(ctx *gin.Context, params interface{}) (r *Context, isAllow bool) {
@@ -41,6 +47,7 @@
 	// validate params
 	if params != nil {
 		if err := r.ctx.ShouldBind(params); err != nil {
+			logx.Errorf("validate params error:%v", err)
 			r.Fail(ecode.ParamsErr)
 			return
 		}
@@ -71,6 +78,14 @@
 	})
 }
 
+func (slf *Context) ResultList(data interface{}, total int64) {
+	slf.ctx.JSON(http.StatusOK, ResponseList{
+		Data:  data,
+		Total: total,
+		Code:  ecode.OK,
+	})
+}
+
 func (slf *Context) Ok() {
 	slf.Result(ecode.OK, map[string]interface{}{}, "")
 }
@@ -83,6 +98,10 @@
 	slf.Result(errCode, map[string]interface{}{}, ecode.GetMsg(errCode))
 }
 
+func (slf *Context) FailWithMsg(errCode int, msg string) {
+	slf.Result(errCode, map[string]interface{}{}, msg)
+}
+
 func (slf *Context) FailWithDetailed(errCode int, data interface{}) {
 	slf.Result(errCode, data, ecode.GetMsg(errCode))
 }

--
Gitblit v1.8.0