|
@@ -45,7 +45,17 @@ func (c *BaseCommonController) ServeJSON(encoding ...bool) {
|
|
|
if baseRes != nil && !baseRes.Success && baseRes.IsSendEmail {
|
|
|
go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "URI:"+c.Ctx.Input.URI()+" ErrMsg:"+baseRes.ErrMsg+";Msg"+baseRes.Msg, utils.EmailSendToUsers)
|
|
|
}
|
|
|
- c.JSON(c.Data["json"], hasIndent, hasEncoding)
|
|
|
+
|
|
|
+ // 数据加密
|
|
|
+ var result interface{}
|
|
|
+ result = c.Data["json"]
|
|
|
+ if utils.RunMode != "debug" {
|
|
|
+ jsonByte, _ := json.Marshal(c.Data["json"])
|
|
|
+ encryptResult := utils.DesBase64Encrypt(jsonByte)
|
|
|
+ result = string(encryptResult)
|
|
|
+ }
|
|
|
+
|
|
|
+ c.JSON(result, hasIndent, hasEncoding)
|
|
|
}
|
|
|
|
|
|
func (c *BaseCommonController) JSON(data interface{}, hasIndent bool, coding bool) error {
|
|
@@ -57,14 +67,6 @@ func (c *BaseCommonController) JSON(data interface{}, hasIndent bool, coding boo
|
|
|
} else {
|
|
|
content, err = json.Marshal(data)
|
|
|
}
|
|
|
- // 测试环境不加密
|
|
|
- encryptResult := make([]byte, 0)
|
|
|
- if utils.RunMode == "release" {
|
|
|
- encryptResult = utils.DesBase64Encrypt(content)
|
|
|
- } else {
|
|
|
- encryptResult = content
|
|
|
- }
|
|
|
-
|
|
|
if err != nil {
|
|
|
http.Error(c.Ctx.Output.Context.ResponseWriter, err.Error(), http.StatusInternalServerError)
|
|
|
return err
|
|
@@ -74,10 +76,10 @@ func (c *BaseCommonController) JSON(data interface{}, hasIndent bool, coding boo
|
|
|
fmt.Println("params")
|
|
|
fmt.Println(params)
|
|
|
requestBody, _ := url.QueryUnescape(string(c.Ctx.Input.RequestBody))
|
|
|
- apiLog.Println("请求地址:", c.Ctx.Input.URI(), "Authorization:", c.Ctx.Input.Header("Authorization"), "RequestBody:", requestBody, "ResponseBody", string(encryptResult), "IP:", ip)
|
|
|
+ apiLog.Println("请求地址:", c.Ctx.Input.URI(), "Authorization:", c.Ctx.Input.Header("Authorization"), "RequestBody:", requestBody, "ResponseBody", string(content), "IP:", ip)
|
|
|
|
|
|
if coding {
|
|
|
- encryptResult = []byte(utils.StringsToJSON(string(encryptResult)))
|
|
|
+ content = []byte(utils.StringsToJSON(string(content)))
|
|
|
}
|
|
|
- return c.Ctx.Output.Body(encryptResult)
|
|
|
+ return c.Ctx.Output.Body(content)
|
|
|
}
|