Эх сурвалжийг харах

fix:数据加密,过滤测试环境和某个接口

Roc 2 жил өмнө
parent
commit
e0e788b95c

+ 1 - 1
controllers/base_auth.go

@@ -160,7 +160,7 @@ func (c *BaseAuthController) JSON(data interface{}, hasIndent bool, coding bool)
 	}
 
 	// 数据加密
-	if utils.RunMode == "release" {
+	if services.CheckEncryption(c.Ctx.Request.URL.Path) {
 		content = utils.DesBase64Encrypt(content)
 	}
 	return c.Ctx.Output.Body(content)

+ 2 - 1
controllers/base_common.go

@@ -141,8 +141,9 @@ func (c *BaseCommonController) JSON(data interface{}, hasIndent bool, coding boo
 	}
 
 	// 数据加密
-	if utils.RunMode == "release" {
+	if services.CheckEncryption(c.Ctx.Request.URL.Path) {
 		content = utils.DesBase64Encrypt(content)
 	}
+
 	return c.Ctx.Output.Body(content)
 }

+ 1 - 1
controllers/base_not_auth.go

@@ -130,7 +130,7 @@ func (c *BaseNotAuthController) JSON(data interface{}, hasIndent bool, coding bo
 	}
 
 	// 数据加密
-	if utils.RunMode == "release" {
+	if services.CheckEncryption(c.Ctx.Request.URL.Path) {
 		content = utils.DesBase64Encrypt(content)
 	}
 	return c.Ctx.Output.Body(content)

+ 1 - 1
controllers/base_pc_not_auth.go

@@ -144,7 +144,7 @@ func (c *BasePcNotAuthController) JSON(data interface{}, hasIndent bool, coding
 	}
 
 	// 数据加密
-	if utils.RunMode == "release" {
+	if services.CheckEncryption(c.Ctx.Request.URL.Path) {
 		content = utils.DesBase64Encrypt(content)
 	}
 	return c.Ctx.Output.Body(content)

+ 17 - 0
services/verify.go

@@ -0,0 +1,17 @@
+package services
+
+import (
+	"fmt"
+	"hongze/hongze_api/utils"
+)
+
+// CheckEncryption 校验需要是否加密
+func CheckEncryption(urlPath string) (ok bool) {
+	fmt.Println(urlPath)
+	if urlPath != `/api/report/share/detail` {
+		if utils.RunMode == "release" {
+			ok = true
+		}
+	}
+	return
+}