|
@@ -184,52 +184,54 @@ func GetPreAuthCode(c *gin.Context) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func GetAuthUrlCallBack(c *gin.Context) { |
|
|
func GetAuthUrlCallBack(c *gin.Context) { |
|
|
authCode := c.DefaultQuery("auth_code", "") |
|
|
|
|
|
if authCode == "" { |
|
|
|
|
|
e.OutErr(c, e.ERR_NOT_FAN, "auth_code获取失败") |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fmt.Println("auth_code>>>>>>>>", authCode) |
|
|
|
|
|
|
|
|
|
|
|
masterId := c.DefaultQuery("masterId", "") |
|
|
|
|
|
wxOpenThirdPartyAppListDb := implement.NewWxOpenThirdPartyAppListDb(db.Db) |
|
|
|
|
|
wxOpenThirdPartyAppList, err := wxOpenThirdPartyAppListDb.GetWxOpenThirdPartyAppList(utils.StrToInt(masterId)) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if wxOpenThirdPartyAppList == nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_NOT_FAN, "未查询到对应三方应用记录") |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
wxApiService, err := wechat.NewWxApiService(masterId, wxOpenThirdPartyAppList.Appid, wxOpenThirdPartyAppList.AppSecret) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
resp, err := wxApiService.GetAuthorizerAccessTokenByAuthCode(authCode) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
userWxAppletListDb := implement.NewUserWxAppletListDb(db.Db) |
|
|
|
|
|
userWxAppletList, err := userWxAppletListDb.GetUserWxAppletListByAppId(resp.AuthorizationInfo.AuthorizerAppid) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if userWxAppletList == nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_NOT_FAN, "未查询到小程序应用记录") |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
userWxAppletList.AuthorizerRefreshToken = resp.AuthorizationInfo.AuthorizerRefreshToken |
|
|
|
|
|
_, err = userWxAppletListDb.UpdateUserWxAppletList(userWxAppletList, "authorizer_refresh_token") |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
c.String(http.StatusOK, "ok") |
|
|
|
|
|
|
|
|
//authCode := c.DefaultQuery("auth_code", "") |
|
|
|
|
|
//if authCode == "" { |
|
|
|
|
|
// e.OutErr(c, e.ERR_NOT_FAN, "auth_code获取失败") |
|
|
|
|
|
// return |
|
|
|
|
|
//} |
|
|
|
|
|
// |
|
|
|
|
|
//fmt.Println("auth_code>>>>>>>>", authCode) |
|
|
|
|
|
// |
|
|
|
|
|
//masterId := c.DefaultQuery("masterId", "") |
|
|
|
|
|
//wxOpenThirdPartyAppListDb := implement.NewWxOpenThirdPartyAppListDb(db.Db) |
|
|
|
|
|
//wxOpenThirdPartyAppList, err := wxOpenThirdPartyAppListDb.GetWxOpenThirdPartyAppList(utils.StrToInt(masterId)) |
|
|
|
|
|
//if err != nil { |
|
|
|
|
|
// return |
|
|
|
|
|
//} |
|
|
|
|
|
//if wxOpenThirdPartyAppList == nil { |
|
|
|
|
|
// e.OutErr(c, e.ERR_NOT_FAN, "未查询到对应三方应用记录") |
|
|
|
|
|
// return |
|
|
|
|
|
//} |
|
|
|
|
|
//wxApiService, err := wechat.NewWxApiService(masterId, wxOpenThirdPartyAppList.Appid, wxOpenThirdPartyAppList.AppSecret) |
|
|
|
|
|
//if err != nil { |
|
|
|
|
|
// e.OutErr(c, e.ERR, err.Error()) |
|
|
|
|
|
// return |
|
|
|
|
|
//} |
|
|
|
|
|
//resp, err := wxApiService.GetAuthorizerAccessTokenByAuthCode(authCode) |
|
|
|
|
|
//if err != nil { |
|
|
|
|
|
// e.OutErr(c, e.ERR, err.Error()) |
|
|
|
|
|
// return |
|
|
|
|
|
//} |
|
|
|
|
|
// |
|
|
|
|
|
//userWxAppletListDb := implement.NewUserWxAppletListDb(db.Db) |
|
|
|
|
|
//userWxAppletList, err := userWxAppletListDb.GetUserWxAppletListByAppId(resp.AuthorizationInfo.AuthorizerAppid) |
|
|
|
|
|
//if err != nil { |
|
|
|
|
|
// return |
|
|
|
|
|
//} |
|
|
|
|
|
//if userWxAppletList == nil { |
|
|
|
|
|
// e.OutErr(c, e.ERR_NOT_FAN, "未查询到小程序应用记录") |
|
|
|
|
|
// return |
|
|
|
|
|
//} |
|
|
|
|
|
//userWxAppletList.AuthorizerRefreshToken = resp.AuthorizationInfo.AuthorizerRefreshToken |
|
|
|
|
|
//_, err = userWxAppletListDb.UpdateUserWxAppletList(userWxAppletList, "authorizer_refresh_token") |
|
|
|
|
|
//if err != nil { |
|
|
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
|
|
// return |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
c.HTML(http.StatusOK, "success.html", gin.H{ |
|
|
|
|
|
"applet_name": "激活鸟", |
|
|
|
|
|
}) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|