|
@@ -143,45 +143,51 @@ public class WeChatController {
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
- if(StringUtils.isBlank(code)){
|
|
|
- String temp = http+constant.call_back_domain+"/prod-api/service-iot"+request.getRequestURI();
|
|
|
- String url = URLDecoder.decode(temp, "UTF-8");
|
|
|
- String sendUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+constant.WE_CHAT_APP_ID+"&redirect_uri="+url+"&response_type=code&scope=snsapi_base&state=abc123#wechat_redirect";
|
|
|
- try{
|
|
|
- System.out.println("sendUrl: "+sendUrl);
|
|
|
- LOGGER.info("sendUrl: "+sendUrl);
|
|
|
- response.sendRedirect(sendUrl);
|
|
|
- }catch (IOException e){
|
|
|
- throw new BusinessException(e.getMessage());
|
|
|
- }
|
|
|
- }else{
|
|
|
- System.out.println("code: "+code);
|
|
|
- LOGGER.info("code: "+code);
|
|
|
- try {
|
|
|
- WxOAuth2AccessToken wxOAuth2AccessToken = wxMpService.getOAuth2Service().getAccessToken(code);
|
|
|
-
|
|
|
- String openid = wxOAuth2AccessToken.getOpenId();
|
|
|
- String access_token = wxOAuth2AccessToken.getAccessToken();
|
|
|
- System.out.println("openid: "+openid);
|
|
|
- LOGGER.info("openid: "+openid);
|
|
|
- LambdaQueryWrapper<MceMbuser> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.eq(MceMbuser::getOpenid,openid).last("LIMIT 1");
|
|
|
- MceMbuser one = mceMbuserService.getOne(queryWrapper);
|
|
|
- if(one != null){
|
|
|
- //String sendUrl = http+constant.call_back_domain+constant.WE_CHAT_INDEX+"?openId="+one.getOpenid();
|
|
|
- String sendUrl = http+constant.call_back_domain+constant.WE_CHAT_INDEX;
|
|
|
- response.sendRedirect(URLDecoder.decode(sendUrl, "UTF-8"));
|
|
|
- }else{
|
|
|
- //String sendUrl = http+constant.call_back_domain+constant.WE_CHAT_LOGIN+"?openId="+openid;
|
|
|
- String sendUrl = http+constant.call_back_domain+constant.WE_CHAT_LOGIN;
|
|
|
- response.sendRedirect(URLDecoder.decode(sendUrl, "UTF-8"));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- throw new BusinessException(e.getMessage());
|
|
|
- }
|
|
|
+ try{
|
|
|
+ String sendUrl = http+constant.call_back_domain+constant.WE_CHAT_LOGIN;
|
|
|
+ response.sendRedirect(URLDecoder.decode(sendUrl, "UTF-8"));
|
|
|
+ }catch (IOException e){
|
|
|
+ throw new BusinessException(e.getMessage());
|
|
|
}
|
|
|
+// if(StringUtils.isBlank(code)){
|
|
|
+// String temp = http+constant.call_back_domain+"/prod-api/service-iot"+request.getRequestURI();
|
|
|
+// String url = URLDecoder.decode(temp, "UTF-8");
|
|
|
+// String sendUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+constant.WE_CHAT_APP_ID+"&redirect_uri="+url+"&response_type=code&scope=snsapi_base&state=abc123#wechat_redirect";
|
|
|
+// try{
|
|
|
+// System.out.println("sendUrl: "+sendUrl);
|
|
|
+// LOGGER.info("sendUrl: "+sendUrl);
|
|
|
+// response.sendRedirect(sendUrl);
|
|
|
+// }catch (IOException e){
|
|
|
+// throw new BusinessException(e.getMessage());
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// System.out.println("code: "+code);
|
|
|
+// LOGGER.info("code: "+code);
|
|
|
+// try {
|
|
|
+// WxOAuth2AccessToken wxOAuth2AccessToken = wxMpService.getOAuth2Service().getAccessToken(code);
|
|
|
+//
|
|
|
+// String openid = wxOAuth2AccessToken.getOpenId();
|
|
|
+// String access_token = wxOAuth2AccessToken.getAccessToken();
|
|
|
+// System.out.println("openid: "+openid);
|
|
|
+// LOGGER.info("openid: "+openid);
|
|
|
+// LambdaQueryWrapper<MceMbuser> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+// queryWrapper.eq(MceMbuser::getOpenid,openid).last("LIMIT 1");
|
|
|
+// MceMbuser one = mceMbuserService.getOne(queryWrapper);
|
|
|
+// if(one != null){
|
|
|
+// //String sendUrl = http+constant.call_back_domain+constant.WE_CHAT_INDEX+"?openId="+one.getOpenid();
|
|
|
+// String sendUrl = http+constant.call_back_domain+constant.WE_CHAT_INDEX;
|
|
|
+// response.sendRedirect(URLDecoder.decode(sendUrl, "UTF-8"));
|
|
|
+// }else{
|
|
|
+// //String sendUrl = http+constant.call_back_domain+constant.WE_CHAT_LOGIN+"?openId="+openid;
|
|
|
+// String sendUrl = http+constant.call_back_domain+constant.WE_CHAT_LOGIN;
|
|
|
+// response.sendRedirect(URLDecoder.decode(sendUrl, "UTF-8"));
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// } catch (Exception e) {
|
|
|
+// throw new BusinessException(e.getMessage());
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
}
|
|
|
|