Forráskód Böngészése

Merge branch 'ht_mini_response_decode' into debug

kobe6258 6 napja
szülő
commit
34e750bb77
2 módosított fájl, 13 hozzáadás és 12 törlés
  1. 6 11
      controllers/base_auth.go
  2. 7 1
      facade/instance/ht_mini_facade.go

+ 6 - 11
controllers/base_auth.go

@@ -194,17 +194,12 @@ func (c *BaseAuthController) JSON(data interface{}, hasIndent bool, coding bool)
 		requestBody = c.Ctx.Input.URI()
 	}
 	c.logUri(content, requestBody, ip)
-	//if coding {
-	//	content = []byte(utils.StringsToJSON(string(content)))
-	//}
-	//if utils.RunMode != "debug" {
-	//	content = utils.DesBase64Encrypt(content, utils.DesKey)
-	//	// get请求时,不加双引号就获取不到数据,不知道什么原因,所以还是在前后加上双引号吧
-	//	content = []byte(`"` + string(content) + `"`)
-	//}
-	content = utils.DesBase64Encrypt(content, utils.DesKey)
-	// get请求时,不加双引号就获取不到数据,不知道什么原因,所以还是在前后加上双引号吧
-	content = []byte(`"` + string(content) + `"`)
+	// 除了prod,release和debug均进行加密(为了兼容nh)
+	if utils.RunMode != "prod" {
+		content = utils.DesBase64Encrypt(content, utils.DesKey)
+		// get请求时,不加双引号就获取不到数据,不知道什么原因,所以还是在前后加上双引号吧
+		content = []byte(`"` + string(content) + `"`)
+	}
 	if coding {
 		content = []byte(utils.StringsToJSON(string(content)))
 	}

+ 7 - 1
facade/instance/ht_mini_facade.go

@@ -56,7 +56,13 @@ func dealChartInfo(baseReq facade.BaseRequest) (request HTRequest, err error) {
 	return
 }
 func parseResult(resp string) (response HTResponse, err error) {
-	err = json.Unmarshal([]byte(resp), &response)
+	var respBytes []byte
+	if utils.RunMode != "debug" {
+		respBytes = utils.DesBase64Decrypt([]byte(resp), utils.ETA_MINI_DES_KEY)
+	} else {
+		respBytes = []byte(resp)
+	}
+	err = json.Unmarshal(respBytes, &response)
 	if err != nil {
 		utils.FileLog.Error("收藏失败,解析应答失败:%v,应答结果:%s", err.Error(), resp)
 	}