|
@@ -91,7 +91,7 @@ public class AuthorizationController {
|
|
|
private final DistributeService distributeService;
|
|
private final DistributeService distributeService;
|
|
|
|
|
|
|
|
@GetMapping(value = "/weChat")
|
|
@GetMapping(value = "/weChat")
|
|
|
- public void base(String url, Long sharedId, Integer dsType, Long popularizeId, String authType, Integer type, HttpServletResponse response) throws Exception {
|
|
|
|
|
|
|
+ public void base(String url, Long sharedId, Integer dsType, Long popularizeId, String authType, Long tid, HttpServletResponse response) throws Exception {
|
|
|
|
|
|
|
|
log.info("微信授权转跳. url: {},authType:{}", url, authType);
|
|
log.info("微信授权转跳. url: {},authType:{}", url, authType);
|
|
|
|
|
|
|
@@ -101,10 +101,10 @@ public class AuthorizationController {
|
|
|
|
|
|
|
|
Long mappingId = SEQUENCE.nextId();
|
|
Long mappingId = SEQUENCE.nextId();
|
|
|
redisService.set(mappingId.toString(), url, 60 * 60 * 24L);
|
|
redisService.set(mappingId.toString(), url, 60 * 60 * 24L);
|
|
|
- AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId).setSharedId(sharedId).setDsType(dsType).setPid(popularizeId).setType(type);
|
|
|
|
|
|
|
+ AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId).setSharedId(sharedId).setDsType(dsType).setPid(popularizeId).setTid(tid);
|
|
|
String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
|
|
String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
|
|
|
|
|
|
|
|
- response.sendRedirect(authorizationService.createUrl(state, authType, type));
|
|
|
|
|
|
|
+ response.sendRedirect(authorizationService.createUrl(state, authType, tid));
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -121,7 +121,7 @@ public class AuthorizationController {
|
|
|
String json = Codec.DoBase64.custom().setData(state).decodeAsText();
|
|
String json = Codec.DoBase64.custom().setData(state).decodeAsText();
|
|
|
AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
|
|
AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
|
|
|
|
|
|
|
|
- AuthToken token = weChatService.getAuthToken(code, weChatService.getWxAppId(re.getType()));
|
|
|
|
|
|
|
+ AuthToken token = weChatService.getAuthToken(code, weChatService.getWxAppId(re.getTid()));
|
|
|
|
|
|
|
|
// 根据openid 与 access_token 获取用户信息
|
|
// 根据openid 与 access_token 获取用户信息
|
|
|
GzhOAuth2UserInfo userinfo = weChatService.getUserInfo(token.getAccessToken(), token.getOpenid());
|
|
GzhOAuth2UserInfo userinfo = weChatService.getUserInfo(token.getAccessToken(), token.getOpenid());
|
|
@@ -167,7 +167,7 @@ public class AuthorizationController {
|
|
|
String json = Codec.DoBase64.custom().setData(state).decodeAsText();
|
|
String json = Codec.DoBase64.custom().setData(state).decodeAsText();
|
|
|
AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
|
|
AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
|
|
|
|
|
|
|
|
- AuthToken token = weChatService.getAuthToken(code, weChatService.getWxAppId(re.getType()));
|
|
|
|
|
|
|
+ AuthToken token = weChatService.getAuthToken(code, weChatService.getWxAppId(re.getTid()));
|
|
|
|
|
|
|
|
// 查询用户期望转跳的url
|
|
// 查询用户期望转跳的url
|
|
|
String url = redisService.getStr(re.getMappingId().toString());
|
|
String url = redisService.getStr(re.getMappingId().toString());
|
|
@@ -187,11 +187,11 @@ public class AuthorizationController {
|
|
|
* 微信js-sdk 权限验证
|
|
* 微信js-sdk 权限验证
|
|
|
*/
|
|
*/
|
|
|
@RequestMapping(value = "/jsTicket", method = RequestMethod.GET)
|
|
@RequestMapping(value = "/jsTicket", method = RequestMethod.GET)
|
|
|
- public Result<JsSdkTicket> ticket(String url, Integer type) throws Exception {
|
|
|
|
|
|
|
+ public Result<JsSdkTicket> ticket(String url, Long tid) throws Exception {
|
|
|
if (StringUtils.isBlank(url)) {
|
|
if (StringUtils.isBlank(url)) {
|
|
|
throw BusinessRuntimeException.getInstance("请输入授权网址.");
|
|
throw BusinessRuntimeException.getInstance("请输入授权网址.");
|
|
|
}
|
|
}
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(authorizationService.getJsTicket(weChatService.getWxAppId(type), url));
|
|
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(authorizationService.getJsTicket(weChatService.getWxAppId(tid), url));
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|