|
@@ -46,16 +46,7 @@ func (c *BaseCommonController) ServeJSON(encoding ...bool) {
|
|
|
go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "URI:"+c.Ctx.Input.URI()+" ErrMsg:"+baseRes.ErrMsg+";Msg"+baseRes.Msg, utils.EmailSendToUsers)
|
|
|
}
|
|
|
|
|
|
- // 数据加密
|
|
|
- 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)
|
|
|
+ c.JSON(c.Data["json"], hasIndent, hasEncoding)
|
|
|
}
|
|
|
|
|
|
func (c *BaseCommonController) JSON(data interface{}, hasIndent bool, coding bool) error {
|
|
@@ -81,5 +72,16 @@ func (c *BaseCommonController) JSON(data interface{}, hasIndent bool, coding boo
|
|
|
if coding {
|
|
|
content = []byte(utils.StringsToJSON(string(content)))
|
|
|
}
|
|
|
+
|
|
|
+ // 如果不是debug分支的话,那么需要加密返回
|
|
|
+ if utils.RunMode != "debug" {
|
|
|
+ content = utils.DesBase64Encrypt(content)
|
|
|
+ // get请求时,不加双引号就获取不到数据,不知道什么原因,所以还是在前后加上双引号吧
|
|
|
+ content = []byte(`"` + string(content) + `"`)
|
|
|
+ }
|
|
|
+ if coding {
|
|
|
+ content = []byte(utils.StringsToJSON(string(content)))
|
|
|
+ }
|
|
|
+
|
|
|
return c.Ctx.Output.Body(content)
|
|
|
}
|