Bladeren bron

Merge branch 'usky-zyj' of uskycloud/usky-modules into server-165

James 9 maanden geleden
bovenliggende
commit
6efa8039f3

+ 26 - 20
service-iot/service-iot-biz/src/main/java/com/usky/iot/controller/web/WeChatController.java

@@ -118,37 +118,43 @@ public class WeChatController {
      * 跳转首页权限
      */
     @GetMapping("/getPageAuthorization")
-    public void getPageAuthorization(@RequestParam(value = "openId",required = false) String openId) throws UnsupportedEncodingException {
+    public ApiResult<MceMbuser> getPageAuthorization(@RequestParam(value = "openId",required = false) String openId) throws UnsupportedEncodingException {
         String http = "https://";
         String code = request.getParameter("code");
         System.out.println("String openId:  "+openId);
         LOGGER.info("String openId:  "+openId);
 
         if((openId != null) && (openId != "")){
-            try{
                 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+"?flag=true";
-                    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+"?flag=true";
-                    response.sendRedirect(URLDecoder.decode(sendUrl, "UTF-8"));
-                }
-            }catch (IOException e){
-                throw new BusinessException(e.getMessage());
-            }
+
+                return ApiResult.success(one);
+//            try{
+//                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+"?flag=true";
+//                    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+"?flag=true";
+//                    response.sendRedirect(URLDecoder.decode(sendUrl, "UTF-8"));
+//                }
+//            }catch (IOException e){
+//                throw new BusinessException(e.getMessage());
+//            }
 
         }else{
-            try{
-                String sendUrl = http+constant.call_back_domain+constant.WE_CHAT_LOGIN+"?flag=true";
-                response.sendRedirect(URLDecoder.decode(sendUrl, "UTF-8"));
-            }catch (IOException e){
-                throw new BusinessException(e.getMessage());
-            }
+            throw new BusinessException("openId null");
+//            try{
+//                String sendUrl = http+constant.call_back_domain+constant.WE_CHAT_LOGIN+"?flag=true";
+//                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");