|
@@ -3,13 +3,20 @@ package controllers
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"errors"
|
|
|
+ "eta/eta_mini_ht_api/common/component/config"
|
|
|
logger "eta/eta_mini_ht_api/common/component/log"
|
|
|
+ "eta/eta_mini_ht_api/common/contants"
|
|
|
"eta/eta_mini_ht_api/common/exception"
|
|
|
"eta/eta_mini_ht_api/common/http"
|
|
|
+ "eta/eta_mini_ht_api/common/utils/auth"
|
|
|
"github.com/beego/beego/v2/server/web"
|
|
|
"net/url"
|
|
|
)
|
|
|
|
|
|
+var (
|
|
|
+ htConfig = config.GetConfig(contants.HT).(*config.HTBizConfig)
|
|
|
+)
|
|
|
+
|
|
|
type WrapData struct {
|
|
|
Msg string
|
|
|
Data interface{}
|
|
@@ -40,7 +47,15 @@ func (b *BaseController) FailResponse(errInfo error, msg string) {
|
|
|
ErrMsg: etaError.ErrorMsg,
|
|
|
ErrCode: etaError.ErrorCode,
|
|
|
Data: nil}
|
|
|
- b.Data["json"] = retData
|
|
|
+ content, err := json.Marshal(retData)
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("加密失败")
|
|
|
+ } else {
|
|
|
+ if htConfig.NeedEncode() {
|
|
|
+ content = auth.DesBase64Encrypt(content, htConfig.GetDesCode())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ b.Data["json"] = content
|
|
|
b.ServeJSON()
|
|
|
}
|
|
|
|
|
@@ -55,7 +70,15 @@ func (b *BaseController) JsonResult(status int, errCode int, errMsg string, msg
|
|
|
Success: success}
|
|
|
|
|
|
b.Ctx.Output.SetStatus(status)
|
|
|
- b.Data["json"] = retData
|
|
|
+ content, err := json.Marshal(retData)
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("加密失败")
|
|
|
+ } else {
|
|
|
+ if htConfig.NeedEncode() {
|
|
|
+ content = auth.DesBase64Encrypt(content, htConfig.GetDesCode())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ b.Data["json"] = content
|
|
|
b.ServeJSON()
|
|
|
}
|
|
|
|