From be03fcc691a22ddab713f4f86151ce7a6b9a235d Mon Sep 17 00:00:00 2001 From: hujiebin Date: Sun, 25 Jun 2023 16:03:45 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=88=86=E9=A1=B5=E5=85=BC?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resp/response.go | 17 +++++++++++------ route/middleHandle.go | 6 ++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/resp/response.go b/resp/response.go index 1b8c4db..e432d1b 100755 --- a/resp/response.go +++ b/resp/response.go @@ -38,7 +38,6 @@ func ResponseOk(c *gin.Context, data interface{}) { Code: myerr.GetSuccessCode(), Message: myerr.GetSuccessMsg(), OperationMessage: myerr.GetSuccessMsg(), - Data: data, // todo,3.9.0覆盖完整之后去掉 } if _, ok := c.Get(mycontext.InnerEncrypt); ok { //response.Edata = utils.EncryptionData(data, []byte("484194d4d0f968a7")) @@ -58,15 +57,21 @@ func ResponsePageBaseOk(c *gin.Context, data interface{}, nextPageIndex int, has if data == nil { data = make([]interface{}, 0) } + pageData := req.PageRespBase{ + NextPageIndex: nextPageIndex, + HasNextPage: hasNextPage, + Data: data, + } response := Response{ Code: myerr.GetSuccessCode(), Message: myerr.GetSuccessMsg(), OperationMessage: myerr.GetSuccessMsg(), - Data: req.PageRespBase{ - NextPageIndex: nextPageIndex, - HasNextPage: hasNextPage, - Data: data, - }, + } + if _, ok := c.Get(mycontext.InnerEncrypt); ok { + //response.Edata = utils.EncryptionData(data, []byte("484194d4d0f968a7")) + response.Edata = utils.EncryptionData(pageData, []byte("hilo!@#$%^&*()_+")) + } else { + response.Data = pageData } c.JSON(http.StatusOK, response) } diff --git a/route/middleHandle.go b/route/middleHandle.go index 5c3e9bc..de57538 100755 --- a/route/middleHandle.go +++ b/route/middleHandle.go @@ -137,8 +137,10 @@ func LoggerHandle(c *gin.Context) { // 加密Handle func EncryptHandle(c *gin.Context) { - if value, ok := c.Get(mycontext.APP_VERSION); ok { - if high, _ := utils.CompareVersion(value.(string), "> 3.9.0"); high { + header := c.Request.Header + appVersion := header.Get("Appversion") + if len(appVersion) > 0 { + if high, _ := utils.CompareVersion(appVersion, "> 3.9.0"); high { c.Set(mycontext.InnerEncrypt, true) } } -- 2.22.0