Browse Source

fix struct field type bug

Jerry 5 years ago
parent
commit
c89dbe78c4
2 changed files with 12 additions and 11 deletions
  1. 10 11
      wechat/model.go
  2. 2 0
      wechat/service_api.go

+ 10 - 11
wechat/model.go

@@ -409,23 +409,22 @@ type RefundNotify struct {
 
 type Code2SessionRsp struct {
 	SessionKey string `json:"session_key,omitempty"` // 会话密钥
-	ExpiresIn  string `json:"expires_in,omitempty"`  // SessionKey超时时间(秒)
 	Openid     string `json:"openid,omitempty"`      // 用户唯一标识
 	Unionid    string `json:"unionid,omitempty"`     // 用户在开放平台的唯一标识符
-	Errcode    string `json:"errcode,omitempty"`     // 错误码
+	Errcode    int    `json:"errcode,omitempty"`     // 错误码
 	Errmsg     string `json:"errmsg,omitempty"`      // 错误信息
 }
 
 type PaidUnionId struct {
 	Unionid string `json:"unionid,omitempty"` // 用户在开放平台的唯一标识符
-	Errcode string `json:"errcode,omitempty"` // 错误码
+	Errcode int    `json:"errcode,omitempty"` // 错误码
 	Errmsg  string `json:"errmsg,omitempty"`  // 错误信息
 }
 
 type AccessToken struct {
 	AccessToken string `json:"access_token,omitempty"` // 获取到的凭证
-	ExpiresIn   string `json:"expires_in,omitempty"`   // SessionKey超时时间(秒)
-	Errcode     string `json:"errcode,omitempty"`      // 错误码
+	ExpiresIn   int    `json:"expires_in,omitempty"`   // SessionKey超时时间(秒)
+	Errcode     int    `json:"errcode,omitempty"`      // 错误码
 	Errmsg      string `json:"errmsg,omitempty"`       // 错误信息
 }
 
@@ -492,22 +491,22 @@ type OpenIdByAuthCodeRsp struct {
 // App应用微信第三方登录,code换取access_token
 type AppLoginAccessToken struct {
 	AccessToken  string `json:"access_token,omitempty"`
-	ExpiresIn    string `json:"expires_in,omitempty"`
-	Openid       string `json:"openid,omitempty"`
+	ExpiresIn    int    `json:"expires_in,omitempty"`
 	RefreshToken string `json:"refresh_token,omitempty"`
+	Openid       string `json:"openid,omitempty"`
 	Scope        string `json:"scope,omitempty"`
 	Unionid      string `json:"unionid,omitempty"`
-	Errcode      string `json:"errcode,omitempty"` // 错误码
+	Errcode      int    `json:"errcode,omitempty"` // 错误码
 	Errmsg       string `json:"errmsg,omitempty"`  // 错误信息
 }
 
 // 刷新App应用微信第三方登录后,获取的 access_token
 type RefreshAppLoginAccessTokenRsp struct {
 	AccessToken  string `json:"access_token,omitempty"`
-	ExpiresIn    string `json:"expires_in,omitempty"`
-	Openid       string `json:"openid,omitempty"`
+	ExpiresIn    int    `json:"expires_in,omitempty"`
 	RefreshToken string `json:"refresh_token,omitempty"`
+	Openid       string `json:"openid,omitempty"`
 	Scope        string `json:"scope,omitempty"`
-	Errcode      string `json:"errcode,omitempty"` // 错误码
+	Errcode      int    `json:"errcode,omitempty"` // 错误码
 	Errmsg       string `json:"errmsg,omitempty"`  // 错误信息
 }

+ 2 - 0
wechat/service_api.go

@@ -413,6 +413,7 @@ func DecryptOpenDataToBodyMap(encryptedData, iv, sessionKey string) (bm gopay.Bo
 //    appId:应用唯一标识,在微信开放平台提交应用审核通过后获得
 //    appSecret:应用密钥AppSecret,在微信开放平台提交应用审核通过后获得
 //    code:App用户换取access_token的code
+//    文档:https://developers.weixin.qq.com/doc/oplatform/Website_App/WeChat_Login/Wechat_Login.html
 func GetAppLoginAccessToken(appId, appSecret, code string) (accessToken *AppLoginAccessToken, err error) {
 	accessToken = new(AppLoginAccessToken)
 	url := "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appId + "&secret=" + appSecret + "&code=" + code + "&grant_type=authorization_code"
@@ -428,6 +429,7 @@ func GetAppLoginAccessToken(appId, appSecret, code string) (accessToken *AppLogi
 //    appId:应用唯一标识,在微信开放平台提交应用审核通过后获得
 //    appSecret:应用密钥AppSecret,在微信开放平台提交应用审核通过后获得
 //    code:App用户换取access_token的code
+//    文档:https://developers.weixin.qq.com/doc/oplatform/Website_App/WeChat_Login/Wechat_Login.html
 func RefreshAppLoginAccessToken(appId, refreshToken string) (accessToken *RefreshAppLoginAccessTokenRsp, err error) {
 	accessToken = new(RefreshAppLoginAccessTokenRsp)
 	url := "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=" + appId + "&grant_type=refresh_token&refresh_token=" + refreshToken