From d3bcec43a5e456964b42ce02cd0e022b25b648d3 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期四, 09 七月 2020 08:46:54 +0800
Subject: [PATCH] 优化业主绑定

---
 service-front/src/main/java/com/java110/front/smo/ownerRegister/ownerLogin/impl/OwnerAppRegisterSMOImpl.java |   41 ++++++++++++++++++-----------------------
 1 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/service-front/src/main/java/com/java110/front/smo/ownerRegister/ownerLogin/impl/OwnerAppRegisterSMOImpl.java b/service-front/src/main/java/com/java110/front/smo/ownerRegister/ownerLogin/impl/OwnerAppRegisterSMOImpl.java
index 57c0d68..b9dedef 100644
--- a/service-front/src/main/java/com/java110/front/smo/ownerRegister/ownerLogin/impl/OwnerAppRegisterSMOImpl.java
+++ b/service-front/src/main/java/com/java110/front/smo/ownerRegister/ownerLogin/impl/OwnerAppRegisterSMOImpl.java
@@ -1,11 +1,13 @@
 package com.java110.front.smo.ownerRegister.ownerLogin.impl;
 
 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.front.smo.AppAbstractComponentSMO;
+import com.java110.dto.owner.OwnerAppUserDto;
 import com.java110.front.smo.ownerRegister.ownerLogin.IOwnerAppRegisterSMO;
+import com.java110.utils.constant.ServiceCodeConstant;
 import com.java110.utils.constant.ServiceConstant;
 import com.java110.utils.exception.SMOException;
 import com.java110.utils.util.Assert;
@@ -18,11 +20,13 @@
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 
+import java.util.List;
+
 /**
  * wx鐧诲綍
  */
 @Service("ownerAppRegisterSMOImpl")
-public class OwnerAppRegisterSMOImpl extends AppAbstractComponentSMO implements IOwnerAppRegisterSMO {
+public class OwnerAppRegisterSMOImpl extends AbstractFrontServiceSMO implements IOwnerAppRegisterSMO {
 
     private final static Logger logger = LoggerFactory.getLogger(OwnerAppRegisterSMOImpl.class);
 
@@ -32,29 +36,20 @@
     @Override
     public ResponseEntity<String>
     doLogin(IPageData pd) throws SMOException {
-        return businessProcess(pd);
-    }
-
-    @Override
-    protected void validate(IPageData pd, JSONObject paramIn) {
-
         //super.validatePageInfo(pd);
+
+        JSONObject paramIn = JSONObject.parseObject(pd.getReqData());
 
         Assert.hasKeyAndValue(paramIn, "username", "璇锋眰鎶ユ枃涓湭鍖呭惈鐢ㄦ埛鍚�");
         Assert.hasKeyAndValue(paramIn, "password", "璇锋眰鎶ユ枃涓湭鍖呭惈瀵嗙爜");
         //super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.LIST_ORG);
-    }
-
-    @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);
+        responseEntity = this.callCenterService(restTemplate, pd, loginInfo.toJSONString(), ServiceConstant.SERVICE_API_URL + "/api/user.service.login", HttpMethod.POST);
         if (responseEntity.getStatusCode() != HttpStatus.OK) {
             return responseEntity;
         }
@@ -67,22 +62,21 @@
         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);
+        OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
+        ownerAppUserDto.setUserId(userId);
 
-        if (responseEntity.getStatusCode() != HttpStatus.OK) {
-            return responseEntity;
-        }
+        List<OwnerAppUserDto> ownerAppUserDtos = super.getForApis(pd, ownerAppUserDto, ServiceCodeConstant.LIST_APPUSERBINDINGOWNERS, OwnerAppUserDto.class);
 
         JSONObject ownerInfo = JSONObject.parseObject(responseEntity.getBody().toString());
 
-        if(ownerInfo.getInteger("total") != 1){
-            responseEntity = new ResponseEntity<>("鐢ㄦ埛鏈粦瀹氫笟涓�",HttpStatus.BAD_REQUEST);
+        if (ownerAppUserDtos == null || ownerAppUserDtos.size() < 1) {
+            responseEntity = new ResponseEntity<>("鐢ㄦ埛鏈粦瀹氫笟涓�", HttpStatus.BAD_REQUEST);
             return responseEntity;
         }
 
-        JSONObject appUser = ownerInfo.getJSONArray("auditAppUserBindingOwners").getJSONObject(0);
-        appUser.put("userId",userId);
-        appUser.put("userName",paramIn.getString("username"));
+        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);
@@ -92,6 +86,7 @@
         return new ResponseEntity<>(paramOut.toJSONString(), HttpStatus.OK);
     }
 
+
     public RestTemplate getRestTemplate() {
         return restTemplate;
     }

--
Gitblit v1.8.0