From 55e853b4cf6a00bf5f1bccdd5208c9b5d53289c3 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期三, 17 六月 2020 09:08:14 +0800
Subject: [PATCH] 鉴权登录问题

---
 service-front/src/main/java/com/java110/front/smo/ownerLogin/impl/OwnerAppLoginSMOImpl.java |  311 ++++++++++++++++++++++++++++++---------------------
 1 files changed, 182 insertions(+), 129 deletions(-)

diff --git a/service-front/src/main/java/com/java110/front/smo/ownerLogin/impl/OwnerAppLoginSMOImpl.java b/service-front/src/main/java/com/java110/front/smo/ownerLogin/impl/OwnerAppLoginSMOImpl.java
index e07e07f..8f937df 100644
--- a/service-front/src/main/java/com/java110/front/smo/ownerLogin/impl/OwnerAppLoginSMOImpl.java
+++ b/service-front/src/main/java/com/java110/front/smo/ownerLogin/impl/OwnerAppLoginSMOImpl.java
@@ -2,16 +2,18 @@
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.java110.core.base.smo.front.AbstractFrontServiceSMO;
 import com.java110.core.context.IPageData;
 import com.java110.core.context.PageData;
 import com.java110.core.factory.AuthenticationFactory;
 import com.java110.dto.owner.OwnerAppUserDto;
+import com.java110.dto.user.UserDto;
 import com.java110.front.properties.WechatAuthProperties;
-import com.java110.front.smo.AppAbstractComponentSMO;
 import com.java110.front.smo.ownerLogin.IOwnerAppLoginSMO;
 import com.java110.utils.cache.CommonCache;
 import com.java110.utils.constant.CommonConstant;
 import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.constant.ServiceCodeConstant;
 import com.java110.utils.constant.ServiceConstant;
 import com.java110.utils.constant.WechatConstant;
 import com.java110.utils.exception.SMOException;
@@ -32,6 +34,7 @@
 import java.net.URL;
 import java.net.URLEncoder;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
@@ -39,7 +42,7 @@
  * wx鐧诲綍
  */
 @Service("ownerAppLoginSMOImpl")
-public class OwnerAppLoginSMOImpl extends AppAbstractComponentSMO implements IOwnerAppLoginSMO {
+public class OwnerAppLoginSMOImpl extends AbstractFrontServiceSMO implements IOwnerAppLoginSMO {
 
     private final static Logger logger = LoggerFactory.getLogger(OwnerAppLoginSMOImpl.class);
 
@@ -55,9 +58,113 @@
     private WechatAuthProperties wechatAuthProperties;
 
     @Override
-    public ResponseEntity<String>
-    doLogin(IPageData pd) throws SMOException {
-        return businessProcess(pd);
+    public ResponseEntity<String> doLogin(IPageData pd) throws SMOException {
+        JSONObject paramIn = JSONObject.parseObject(pd.getReqData());
+        Assert.hasKeyAndValue(paramIn, "username", "璇锋眰鎶ユ枃涓湭鍖呭惈鐢ㄦ埛鍚�");
+        Assert.hasKeyAndValue(paramIn, "password", "璇锋眰鎶ユ枃涓湭鍖呭惈瀵嗙爜");
+        logger.debug("doLogin鍏ュ弬锛�" + paramIn.toJSONString());
+        ResponseEntity<String> responseEntity;
+
+        JSONObject loginInfo = JSONObject.parseObject(pd.getReqData());
+
+        loginInfo.put("passwd", AuthenticationFactory.passwdMd5(loginInfo.getString("password")));
+//        responseEntity = this.callCenterService(restTemplate, pd, loginInfo.toJSONString(), ServiceConstant.SERVICE_API_URL + "/api/user.service.login", HttpMethod.POST);
+//        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+//            return responseEntity;
+//        }
+
+     //   JSONObject userInfo = JSONObject.parseObject(responseEntity.getBody());
+        UserDto userDto = new UserDto();
+        userDto.setUserName(loginInfo.getString("userName"));
+        userDto.setPassword(loginInfo.getString("password"));
+        userDto = super.getForApi(pd,userDto,ServiceCodeConstant.SERVICE_CODE_USER_LOGIN,UserDto.class);
+
+        if(userDto == null){
+            responseEntity = new ResponseEntity<>("鐢ㄦ埛鍚嶆垨瀵嗙爜閿欒", HttpStatus.BAD_REQUEST);
+            return responseEntity;
+        }
+
+        //鏍规嵁鐢ㄦ埛鏌ヨ鍟嗘埛淇℃伅
+        String userId = userDto.getUserId();
+
+        pd = PageData.newInstance().builder(userId, "", "", pd.getReqData(),
+                "", "", "", "",
+                pd.getAppId());
+        OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
+        ownerAppUserDto.setUserId(userId);
+        List<OwnerAppUserDto> ownerAppUserDtos = super.getForApis(pd, ownerAppUserDto, ServiceCodeConstant.LIST_APPUSERBINDINGOWNERS, OwnerAppUserDto.class);
+
+
+        if (ownerAppUserDtos == null || ownerAppUserDtos.size() < 1) {
+            responseEntity = new ResponseEntity<>("鐢ㄦ埛鏈粦瀹氫笟涓�", HttpStatus.BAD_REQUEST);
+            return responseEntity;
+        }
+
+        JSONObject appUser = JSONObject.parseObject(JSONObject.toJSONString(ownerAppUserDtos.get(0)));
+        appUser.put("userId", userId);
+        appUser.put("userName", paramIn.getString("username"));
+        JSONObject paramOut = new JSONObject();
+        paramOut.put("result", 0);
+        paramOut.put("owner", appUser);
+        paramOut.put("token", userDto.getToken());
+
+        userDto = new UserDto();
+        userDto.setUserId(ownerAppUserDtos.get(0).getUserId());
+        UserDto tmpUserDto = super.getForApi(pd, userDto, ServiceCodeConstant.QUERY_USER_SECRET, UserDto.class);
+        paramOut.put("key", tmpUserDto.getKey());
+
+        String appId = pd.getAppId();
+
+        if ("992020061452450002".equals(appId)) { //鍏紬鍙�
+            return wechat(pd, paramIn, paramOut, userId, ownerAppUserDtos);
+        } else if ("992019111758490006".equals(appId)) { //灏忕▼搴�
+            return mina(pd, paramIn, paramOut, userId, ownerAppUserDtos);
+        } else {//app
+            return new ResponseEntity<>(paramOut.toJSONString(), HttpStatus.OK);
+        }
+    }
+
+    @Override
+    public ResponseEntity<String> doLoginByKey(IPageData pd) throws SMOException {
+        JSONObject paramIn = JSONObject.parseObject(pd.getReqData());
+        Assert.hasKeyAndValue(paramIn, "key", "璇锋眰鎶ユ枃涓湭鍖呭惈涓存椂绉橀挜");
+        logger.debug("doLogin鍏ュ弬锛�" + paramIn.toJSONString());
+        ResponseEntity<String> responseEntity;
+
+        JSONObject loginInfo = JSONObject.parseObject(pd.getReqData());
+
+        UserDto userDto = new UserDto();
+        userDto.setKey(paramIn.getString("key"));
+        userDto = super.postForApi(pd, userDto, ServiceCodeConstant.SERVICE_CODE_USER_LOGIN, UserDto.class);
+
+
+        //鏍规嵁鐢ㄦ埛鏌ヨ鍟嗘埛淇℃伅
+        String userId = userDto.getUserId();
+
+        pd = PageData.newInstance().builder(userId, "", "", pd.getReqData(),
+                "", "", "", "",
+                pd.getAppId());
+        OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
+        ownerAppUserDto.setUserId(userId);
+        List<OwnerAppUserDto> ownerAppUserDtos = super.getForApis(pd, ownerAppUserDto, ServiceCodeConstant.LIST_APPUSERBINDINGOWNERS, OwnerAppUserDto.class);
+
+
+        if (ownerAppUserDtos == null || ownerAppUserDtos.size() < 1) {
+            responseEntity = new ResponseEntity<>("鐢ㄦ埛鏈粦瀹氫笟涓�", HttpStatus.BAD_REQUEST);
+            return responseEntity;
+        }
+
+        JSONObject appUser = JSONObject.parseObject(JSONObject.toJSONString(ownerAppUserDtos.get(0)));
+        appUser.put("userId", userId);
+        appUser.put("userName", paramIn.getString("username"));
+        JSONObject paramOut = new JSONObject();
+        paramOut.put("code", 0);
+        paramOut.put("msg", "鎴愬姛");
+        paramOut.put("owner", appUser);
+        paramOut.put("token", userDto.getToken());
+        paramOut.put("key", userDto.getKey());
+        return new ResponseEntity<>(paramOut.toJSONString(), HttpStatus.OK);
+
     }
 
     @Override
@@ -65,11 +172,16 @@
         JSONObject paramIn = JSONObject.parseObject(pd.getReqData());
         String authCode = paramIn.getString("code");
         String state = paramIn.getString("state");
-        String urlCode = CommonCache.getAndRemoveValue(paramIn.getString("urlCode"));
+        String paramStr = CommonCache.getAndRemoveValue(paramIn.getString("urlCode"));
 
-        if (StringUtil.isEmpty(urlCode)) {
-            return ResultVo.redirectPage("/#/page/login/login");
+        if (StringUtil.isEmpty(paramStr)) {
+            return ResultVo.redirectPage("/");
         }
+
+        JSONObject param = JSONObject.parseObject(paramStr);
+        String redirectUrl = param.getString("redirectUrl");
+        String errorUrl = param.getString("errorUrl");
+
 
         String url = WechatConstant.APP_GET_ACCESS_TOKEN_URL.replace("APPID", wechatAuthProperties.getWechatAppId())
                 .replace("SECRET", wechatAuthProperties.getWechatAppSecret())
@@ -77,9 +189,9 @@
 
         ResponseEntity<String> paramOut = outRestTemplate.getForEntity(url, String.class);
 
-        logger.debug("璋冪敤寰俊鎹㈠幓token ", paramOut);
+        logger.debug("璋冪敤寰俊鎹㈠幓openId ", paramOut);
         if (paramOut.getStatusCode() != HttpStatus.OK) {
-            return ResultVo.redirectPage("/#/page/login/login");
+            return ResultVo.redirectPage(errorUrl);
 
         }
 
@@ -92,25 +204,21 @@
         pd = PageData.newInstance().builder("-1", "", "", pd.getReqData(),
                 "", "", "", "",
                 pd.getAppId());
-        ResponseEntity responseEntity = this.callCenterService(restTemplate, pd, "", ServiceConstant.SERVICE_API_URL + "/api/owner.listAppUserBindingOwners?openId=" + openId, HttpMethod.GET);
-        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+        OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
+        ownerAppUserDto.setOpenId(openId);
+        List<OwnerAppUserDto> ownerAppUserDtos = super.getForApis(pd, ownerAppUserDto, ServiceCodeConstant.LIST_APPUSERBINDINGOWNERS, OwnerAppUserDto.class);
+
+        if (ownerAppUserDtos == null || ownerAppUserDtos.size() < 1) {
             //灏唎penId鏀惧埌redis 缂撳瓨锛岀粰鍓嶆涓嬪彂涓存椂绁ㄦ嵁
             String code = UUID.randomUUID().toString();
             CommonCache.setValue(code, openId, expireTime);
-            return ResultVo.redirectPage("/#/page/login/login?code=" + code);
-        }
-        JSONObject ownerInfo = JSONObject.parseObject(responseEntity.getBody().toString());
-        if (ownerInfo.getInteger("total") < 1) {
-            //灏唎penId鏀惧埌redis 缂撳瓨锛岀粰鍓嶆涓嬪彂涓存椂绁ㄦ嵁
-            String code = UUID.randomUUID().toString();
-            CommonCache.setValue(code, openId, expireTime);
-            return ResultVo.redirectPage("/#/page/login/login?code=" + code);
+            return ResultVo.redirectPage(errorUrl + "?code=" + code);
         }
 
         // String accessToken = paramObj.getString("access_token");//鏆傛椂涓嶇敤
         Map userMap = new HashMap();
-        userMap.put(CommonConstant.LOGIN_USER_ID, ownerInfo.getString("userId"));
-        userMap.put(CommonConstant.LOGIN_USER_NAME, ownerInfo.getString("appUserName"));
+        userMap.put(CommonConstant.LOGIN_USER_ID, ownerAppUserDtos.get(0).getUserId());
+        userMap.put(CommonConstant.LOGIN_USER_NAME, ownerAppUserDtos.get(0).getAppUserName());
         String token = "";
         try {
             token = AuthenticationFactory.createAndSaveToken(userMap);
@@ -118,7 +226,16 @@
         } catch (Exception e) {
             logger.error("鍒涘缓token澶辫触");
         }
-        return ResultVo.redirectPage(urlCode);
+        //鏌ヨ鐢ㄦ埛key
+        UserDto userDto = new UserDto();
+        userDto.setUserId(ownerAppUserDtos.get(0).getUserId());
+        UserDto tmpUserDto = super.getForApi(pd, userDto, ServiceCodeConstant.QUERY_USER_SECRET, UserDto.class);
+
+//        if(StringUtil.isEmpty(tmpUserDto.getKey())){
+//            tmpUserDto = super.postForApi(pd, tmpUserDto, ServiceCodeConstant.SERVICE_CODE_USER_LOGIN, UserDto.class);
+//        }
+        redirectUrl = redirectUrl + (redirectUrl.indexOf("?") > 0 ? "&key=" + tmpUserDto.getKey() : "?key=" + tmpUserDto.getKey());
+        return ResultVo.redirectPage(redirectUrl);
 
     }
 
@@ -133,10 +250,15 @@
      * @throws SMOException
      */
     @Override
-    public ResponseEntity<String> refreshToken(IPageData pd, String redirectUrl, HttpServletRequest request, HttpServletResponse response) throws SMOException {
+    public ResponseEntity<String> refreshToken(IPageData pd, String redirectUrl,
+                                               String errorUrl,
+                                               HttpServletRequest request, HttpServletResponse response) throws SMOException {
         //鍒嗛厤urlCode
         String urlCode = UUID.randomUUID().toString();
-        CommonCache.setValue(urlCode, redirectUrl, expireTime);
+        JSONObject param = new JSONObject();
+        param.put("redirectUrl", redirectUrl);
+        param.put("errorUrl", errorUrl);
+        CommonCache.setValue(urlCode, param.toJSONString(), expireTime);
 
         URL url = null;
         String openUrl = "";
@@ -170,69 +292,6 @@
         return ResultVo.createResponseEntity(ResultVo.CODE_MACHINE_OK, ResultVo.MSG_OK, urlObj);
     }
 
-    @Override
-    protected void validate(IPageData pd, JSONObject paramIn) {
-
-        Assert.hasKeyAndValue(paramIn, "username", "璇锋眰鎶ユ枃涓湭鍖呭惈鐢ㄦ埛鍚�");
-        Assert.hasKeyAndValue(paramIn, "password", "璇锋眰鎶ユ枃涓湭鍖呭惈瀵嗙爜");
-    }
-
-    @Override
-    protected ResponseEntity<String> doBusinessProcess(IPageData pd, JSONObject paramIn) {
-
-        logger.debug("doLogin鍏ュ弬锛�" + paramIn.toJSONString());
-        ResponseEntity<String> responseEntity;
-
-        JSONObject loginInfo = JSONObject.parseObject(pd.getReqData());
-
-        loginInfo.put("passwd", AuthenticationFactory.passwdMd5(loginInfo.getString("password")));
-        responseEntity = this.callCenterService(restTemplate, pd, loginInfo.toJSONString(), ServiceConstant.SERVICE_API_URL + "/api/user.service.login", HttpMethod.POST);
-        if (responseEntity.getStatusCode() != HttpStatus.OK) {
-            return responseEntity;
-        }
-
-        JSONObject userInfo = JSONObject.parseObject(responseEntity.getBody());
-
-        //鏍规嵁鐢ㄦ埛鏌ヨ鍟嗘埛淇℃伅
-        String userId = userInfo.getString("userId");
-
-        pd = PageData.newInstance().builder(userId, "", "", pd.getReqData(),
-                "", "", "", "",
-                pd.getAppId());
-        responseEntity = this.callCenterService(restTemplate, pd, "", ServiceConstant.SERVICE_API_URL + "/api/owner.listAppUserBindingOwners?userid=" + userId, HttpMethod.GET);
-
-        if (responseEntity.getStatusCode() != HttpStatus.OK) {
-            return responseEntity;
-        }
-
-        JSONObject ownerInfo = JSONObject.parseObject(responseEntity.getBody().toString());
-
-        if (ownerInfo.getInteger("total") < 1) {
-            responseEntity = new ResponseEntity<>("鐢ㄦ埛鏈粦瀹氫笟涓�", HttpStatus.BAD_REQUEST);
-            return responseEntity;
-        }
-
-        JSONArray auditAppUserBindingOwners = ownerInfo.getJSONArray("auditAppUserBindingOwners");
-
-        JSONObject appUser = auditAppUserBindingOwners.getJSONObject(0);
-        appUser.put("userId", userId);
-        appUser.put("userName", paramIn.getString("username"));
-        JSONObject paramOut = new JSONObject();
-        paramOut.put("result", 0);
-        paramOut.put("owner", appUser);
-        paramOut.put("token", userInfo.getString("token"));
-
-        String appId = pd.getAppId();
-
-        if ("992020061452450002".equals(appId)) { //鍏紬鍙�
-            return wechat(pd, paramIn, paramOut, userId, auditAppUserBindingOwners);
-        } else if ("992019111758490006".equals(appId)) { //灏忕▼搴�
-            return mina(pd, paramIn, paramOut, userId, auditAppUserBindingOwners);
-        } else {//app
-            return new ResponseEntity<>(paramOut.toJSONString(), HttpStatus.OK);
-        }
-    }
-
     /**
      * 鍏紬鍙风櫥褰�
      *
@@ -240,11 +299,11 @@
      * @param paramIn
      * @param paramOut
      * @param userId
-     * @param auditAppUserBindingOwners
+     * @param ownerAppUserDtos
      * @return
      */
     private ResponseEntity<String> wechat(IPageData pd, JSONObject paramIn, JSONObject paramOut, String userId,
-                                          JSONArray auditAppUserBindingOwners) {
+                                          List<OwnerAppUserDto> ownerAppUserDtos) {
 
         ResponseEntity<String> responseEntity = null;
         //鏌ヨ寰俊淇℃伅
@@ -262,39 +321,37 @@
             return responseEntity;
         }
 
-        JSONObject curOwnerApp = judgeCurrentOwnerBind(auditAppUserBindingOwners, OwnerAppUserDto.APP_TYPE_WECHAT_MINA);
+        OwnerAppUserDto curOwnerApp = judgeCurrentOwnerBind(ownerAppUserDtos, OwnerAppUserDto.APP_TYPE_WECHAT);
 
         //璇存槑 褰撳墠鐨刼penId 灏辨槸鏈�鏂扮殑
-        if (curOwnerApp != null && openId.equals(curOwnerApp.getString("openId"))) {
+        if (curOwnerApp != null && openId.equals(curOwnerApp.getOpenId())) {
             return new ResponseEntity<>(paramOut.toJSONString(), HttpStatus.OK);
         }
 
         JSONObject userOwnerInfo = new JSONObject();
-
-        userOwnerInfo.put("openId", openId);
-        userOwnerInfo.put("appType", OwnerAppUserDto.APP_TYPE_WECHAT_MINA);
+        OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
+        ownerAppUserDto.setOpenId(openId);
+        ownerAppUserDto.setAppType(OwnerAppUserDto.APP_TYPE_WECHAT);
         if (curOwnerApp != null) {
-            userOwnerInfo.put("appUserId", curOwnerApp.getString("appUserId"));
-            userOwnerInfo.put("communityId", curOwnerApp.getString("communityId"));
+            ownerAppUserDto.setAppUserId(curOwnerApp.getAppUserId());
+            ownerAppUserDto.setCommunityId(curOwnerApp.getCommunityId());
         } else {
-            userOwnerInfo.put("oldAppUserId", auditAppUserBindingOwners.getJSONObject(0).getString("appUserId"));
-            userOwnerInfo.put("appUserId", "-1");
-            userOwnerInfo.put("communityId", auditAppUserBindingOwners.getJSONObject(0).getString("communityId"));
+            ownerAppUserDto.setOldAppUserId(ownerAppUserDtos.get(0).getAppUserId());
+            ownerAppUserDto.setAppUserId("-1");
+            ownerAppUserDto.setCommunityId(ownerAppUserDtos.get(0).getCommunityId());
         }
 
         //鏌ヨ寰俊淇℃伅
         pd = PageData.newInstance().builder(userId, "", "", pd.getReqData(),
                 "", "", "", "",
                 pd.getAppId());
-        responseEntity = this.callCenterService(restTemplate, pd, userOwnerInfo.toJSONString(),
-                ServiceConstant.SERVICE_API_URL + "/api/owner.refreshAppUserBindingOwnerToken", HttpMethod.POST);
-        if (responseEntity.getStatusCode() != HttpStatus.OK) {
-            return responseEntity;
-        }
+
+        super.postForApi(pd, ownerAppUserDto, ServiceCodeConstant.REFRESH_APP_USER_BINDING_OWNER_OPEN_ID,
+                OwnerAppUserDto.class);
         return new ResponseEntity<>(paramOut.toJSONString(), HttpStatus.OK);
     }
 
-    private ResponseEntity<String> mina(IPageData pd, JSONObject paramIn, JSONObject paramOut, String userId, JSONArray auditAppUserBindingOwners) {
+    private ResponseEntity<String> mina(IPageData pd, JSONObject paramIn, JSONObject paramOut, String userId, List<OwnerAppUserDto> ownerAppUserDtos) {
 
         ResponseEntity<String> responseEntity = null;
         //鏌ヨ寰俊淇℃伅
@@ -339,50 +396,46 @@
 
         String openId = responseObj.getString("openid");
 
-        JSONObject curOwnerApp = judgeCurrentOwnerBind(auditAppUserBindingOwners, OwnerAppUserDto.APP_TYPE_WECHAT_MINA);
+        OwnerAppUserDto ownerAppUserDto = judgeCurrentOwnerBind(ownerAppUserDtos, OwnerAppUserDto.APP_TYPE_WECHAT_MINA);
 
         //璇存槑 褰撳墠鐨刼penId 灏辨槸鏈�鏂扮殑
-        if (curOwnerApp != null && openId.equals(curOwnerApp.getString("openId"))) {
+        if (ownerAppUserDto != null && openId.equals(ownerAppUserDto.getOpenId())) {
             return new ResponseEntity<>(paramOut.toJSONString(), HttpStatus.OK);
         }
 
-        JSONObject userOwnerInfo = new JSONObject();
-
-        userOwnerInfo.put("openId", openId);
-        userOwnerInfo.put("appType", OwnerAppUserDto.APP_TYPE_WECHAT_MINA);
-        if (curOwnerApp != null) {
-            userOwnerInfo.put("appUserId", curOwnerApp.getString("appUserId"));
-            userOwnerInfo.put("communityId", curOwnerApp.getString("communityId"));
+        OwnerAppUserDto tmpOwnerAppUserDto = new OwnerAppUserDto();
+        tmpOwnerAppUserDto.setOpenId(openId);
+        tmpOwnerAppUserDto.setAppType(OwnerAppUserDto.APP_TYPE_WECHAT_MINA);
+        if (ownerAppUserDto != null) {
+            tmpOwnerAppUserDto.setAppUserId(ownerAppUserDto.getAppUserId());
+            tmpOwnerAppUserDto.setCommunityId(ownerAppUserDto.getCommunityId());
         } else {
-            userOwnerInfo.put("oldAppUserId", auditAppUserBindingOwners.getJSONObject(0).getString("appUserId"));
-            userOwnerInfo.put("appUserId", "-1");
-            userOwnerInfo.put("communityId", auditAppUserBindingOwners.getJSONObject(0).getString("communityId"));
+            tmpOwnerAppUserDto.setOldAppUserId(ownerAppUserDtos.get(0).getAppUserId());
+            tmpOwnerAppUserDto.setAppUserId("-1");
+            tmpOwnerAppUserDto.setCommunityId(ownerAppUserDtos.get(0).getCommunityId());
         }
-
         //鏌ヨ寰俊淇℃伅
         pd = PageData.newInstance().builder(userId, "", "", pd.getReqData(),
                 "", "", "", "",
                 pd.getAppId());
-        responseEntity = this.callCenterService(restTemplate, pd, userOwnerInfo.toJSONString(),
-                ServiceConstant.SERVICE_API_URL + "/api/owner.refreshAppUserBindingOwnerOpenId", HttpMethod.POST);
-        if (responseEntity.getStatusCode() != HttpStatus.OK) {
-            return responseEntity;
-        }
+
+        super.postForApi(pd, tmpOwnerAppUserDto, ServiceCodeConstant.REFRESH_APP_USER_BINDING_OWNER_OPEN_ID,
+                OwnerAppUserDto.class);
         return new ResponseEntity<>(paramOut.toJSONString(), HttpStatus.OK);
     }
 
     /**
      * 鍒ゆ柇 缁戝畾琛ㄩ噷鏄惁瀛樺湪褰撳墠 绔� 缁戝畾淇℃伅
      *
-     * @param auditAppUserBindingOwners
+     * @param ownerAppUserDtos
      * @param appType
      * @return
      */
-    private JSONObject judgeCurrentOwnerBind(JSONArray auditAppUserBindingOwners, String appType) {
+    private OwnerAppUserDto judgeCurrentOwnerBind(List<OwnerAppUserDto> ownerAppUserDtos, String appType) {
 
-        for (int appUserIndex = 0; appUserIndex < auditAppUserBindingOwners.size(); appUserIndex++) {
-            if (appType.equals(auditAppUserBindingOwners.getJSONObject(appUserIndex).getString("appType"))) {
-                return auditAppUserBindingOwners.getJSONObject(appUserIndex);
+        for (OwnerAppUserDto ownerAppUserDto : ownerAppUserDtos) {
+            if (appType.equals(ownerAppUserDto.getAppType())) {
+                return ownerAppUserDto;
             }
         }
         return null;

--
Gitblit v1.8.0