|
@@ -4,7 +4,6 @@ import (
|
|
|
"encoding/json"
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
- "hongze/hongze_api/models"
|
|
|
"hongze/hongze_api/services/alarm_msg"
|
|
|
"hongze/hongze_api/utils"
|
|
|
"io/ioutil"
|
|
@@ -12,12 +11,22 @@ import (
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
+type WxTokenResp struct {
|
|
|
+ Ret int
|
|
|
+ Msg string
|
|
|
+ ErrMsg string
|
|
|
+ ErrCode string
|
|
|
+ Data WxTokenData
|
|
|
+ Success bool `description:"true 执行成功,false 执行失败"`
|
|
|
+ IsSendEmail bool `json:"-"`
|
|
|
+}
|
|
|
+
|
|
|
type WxTokenReq struct {
|
|
|
WxAppId string `description:"公众号appId"`
|
|
|
WxAppSecret string `description:"公众号appSecret"`
|
|
|
}
|
|
|
|
|
|
-type WxTokenResp struct {
|
|
|
+type WxTokenData struct {
|
|
|
AccessToken string `description:"微信token"`
|
|
|
}
|
|
|
|
|
@@ -59,7 +68,7 @@ func GetAccessToken(tokenReq WxTokenReq) (accessToken string, err error, errMsg
|
|
|
errMsg = "ioutil.ReadAll Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- result := new(models.BaseResponse)
|
|
|
+ result := new(WxTokenResp)
|
|
|
err = json.Unmarshal(b, &result)
|
|
|
if err != nil {
|
|
|
errMsg = "json.Unmarshal Err:" + err.Error()
|
|
@@ -70,8 +79,7 @@ func GetAccessToken(tokenReq WxTokenReq) (accessToken string, err error, errMsg
|
|
|
errMsg = "请求失败:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- data := result.Data.(WxTokenResp)
|
|
|
- accessToken = data.AccessToken
|
|
|
+ accessToken = result.Data.AccessToken
|
|
|
if accessToken == "" {
|
|
|
err = errors.New("请求accessToken失败")
|
|
|
errMsg = "请求accessToken失败"
|