Sfoglia il codice sorgente

优化小程序无法登录问题

java110 5 anni fa
parent
commit
4ed7ff50ee

+ 12 - 0
java110-bean/src/main/java/com/java110/dto/smallWeChat/SmallWeChatDto.java

@@ -1,9 +1,11 @@
 package com.java110.dto.smallWeChat;
 
 import com.java110.dto.PageDto;
+import com.java110.dto.smallWechatAttr.SmallWechatAttrDto;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @ClassName FloorDto
@@ -34,6 +36,8 @@ public class SmallWeChatDto extends PageDto implements Serializable {
     private String objTypeName;
     private String weChatType;
 
+    private List<SmallWechatAttrDto> smallWechatAttrs;
+
 
     public Date getCreateTime() {
         return createTime;
@@ -146,4 +150,12 @@ public class SmallWeChatDto extends PageDto implements Serializable {
     public void setWeChatType(String weChatType) {
         this.weChatType = weChatType;
     }
+
+    public List<SmallWechatAttrDto> getSmallWechatAttrs() {
+        return smallWechatAttrs;
+    }
+
+    public void setSmallWechatAttrs(List<SmallWechatAttrDto> smallWechatAttrs) {
+        this.smallWechatAttrs = smallWechatAttrs;
+    }
 }

+ 22 - 0
service-front/src/main/java/com/java110/front/controller/wechat/WechatGatewayController.java

@@ -6,6 +6,8 @@ import com.java110.core.base.controller.BaseController;
 import com.java110.core.context.IPageData;
 import com.java110.core.context.PageData;
 import com.java110.core.factory.AuthenticationFactory;
+import com.java110.dto.smallWeChat.SmallWeChatDto;
+import com.java110.dto.smallWechatAttr.SmallWechatAttrDto;
 import com.java110.front.smo.wechatGateway.IWechatGatewaySMO;
 import com.java110.utils.cache.MappingCache;
 import com.java110.utils.constant.WechatConstant;
@@ -25,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.Arrays;
+import java.util.List;
 
 /**
  * @ClassName WechatController
@@ -57,6 +60,25 @@ public class WechatGatewayController extends BaseController {
         String timestamp = request.getParameter("timestamp");
         String nonce = request.getParameter("nonce");
         String echostr = request.getParameter("echostr");
+        String communityId = request.getParameter("communityId");
+        String java110AppId = request.getParameter("java110AppId");
+        IPageData pd = PageData.newInstance().builder("-1", "", "", "",
+                "", "", "", "",
+                java110AppId);
+        if(!StringUtil.isEmpty(communityId)){
+            SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
+            smallWeChatDto.setObjType(SmallWeChatDto.OBJ_TYPE_COMMUNITY);
+            smallWeChatDto.setObjId(communityId);
+            smallWeChatDto = wechatGatewaySMOImpl.getSmallWechat(pd,smallWeChatDto);
+
+            if(smallWeChatDto !=null){
+                List<SmallWechatAttrDto> smallWechatAttrDtos = smallWeChatDto.getSmallWechatAttrs();
+
+                if(smallWechatAttrDtos != null){
+                   // for()
+                }
+            }
+        }
         String responseStr = "";
         logger.debug("token = " + token + "||||" + "signature = " + signature + "|||" + "timestamp = "
                 + timestamp + "|||" + "nonce = " + nonce + "|||" + "echostr = " + echostr);

+ 1 - 1
service-front/src/main/java/com/java110/front/smo/ownerLogin/impl/OwnerAppLoginSMOImpl.java

@@ -368,7 +368,7 @@ public class OwnerAppLoginSMOImpl extends AbstractFrontServiceSMO implements IOw
                 pd.getAppId());
         responseEntity = this.callCenterService(restTemplate, pd, "",
                 ServiceConstant.SERVICE_API_URL + "/api/smallWeChat.listSmallWeChats?appId="
-                        + paramIn.getString("appId") + "&page=1&row=1", HttpMethod.GET);
+                        + paramIn.getString("appId") + "&page=1&row=1&communityId="+ownerAppUserDtos.get(0).getCommunityId(), HttpMethod.GET);
 
         if (responseEntity.getStatusCode() != HttpStatus.OK) {
             return responseEntity;

+ 9 - 0
service-front/src/main/java/com/java110/front/smo/wechatGateway/IWechatGatewaySMO.java

@@ -1,6 +1,7 @@
 package com.java110.front.smo.wechatGateway;
 
 import com.java110.core.context.IPageData;
+import com.java110.dto.smallWeChat.SmallWeChatDto;
 import com.java110.utils.exception.SMOException;
 import org.springframework.http.ResponseEntity;
 
@@ -19,4 +20,12 @@ public interface IWechatGatewaySMO {
      * @throws SMOException 业务代码层
      */
     ResponseEntity<String> gateway(IPageData pd) throws Exception;
+
+    /**
+     * 查询微信信息
+     *
+     * @param smallWeChatDto
+     * @return
+     */
+    SmallWeChatDto getSmallWechat(IPageData pd, SmallWeChatDto smallWeChatDto);
 }

+ 20 - 0
service-front/src/main/java/com/java110/front/smo/wechatGateway/impl/WechatGatewaySMOImpl.java

@@ -5,10 +5,13 @@ import com.java110.core.base.smo.front.AbstractFrontServiceSMO;
 import com.java110.core.context.IPageData;
 import com.java110.core.factory.WechatFactory;
 import com.java110.dto.owner.OwnerAppUserDto;
+import com.java110.dto.smallWeChat.SmallWeChatDto;
+import com.java110.dto.smallWechatAttr.SmallWechatAttrDto;
 import com.java110.front.properties.WechatAuthProperties;
 import com.java110.front.smo.wechatGateway.IWechatGatewaySMO;
 import com.java110.utils.cache.MappingCache;
 import com.java110.utils.constant.ServiceCodeConstant;
+import com.java110.utils.constant.ServiceCodeSmallWeChatConstant;
 import com.java110.utils.constant.WechatConstant;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.StringUtil;
@@ -74,6 +77,23 @@ public class WechatGatewaySMOImpl extends AbstractFrontServiceSMO implements IWe
         return new ResponseEntity<>(responseStr, HttpStatus.OK);
     }
 
+    @Override
+    public SmallWeChatDto getSmallWechat(IPageData pd, SmallWeChatDto smallWeChatDto) {
+
+        List<SmallWeChatDto> smallWeChatDtos = super.getForApis(pd, smallWeChatDto, ServiceCodeSmallWeChatConstant.LIST_SMALL_WE_CHATS, SmallWeChatDto.class);
+        if (smallWeChatDtos == null || smallWeChatDtos.size() < 1) {
+            return null;
+        }
+        smallWeChatDto = smallWeChatDtos.get(0);
+        SmallWechatAttrDto smallWechatAttrDto = new SmallWechatAttrDto();
+        smallWechatAttrDto.setCommunityId(smallWeChatDto.getObjId());
+        smallWechatAttrDto.setWechatId(smallWeChatDto.getWeChatId());
+        List<SmallWechatAttrDto> smallWechatAttrs = super.getForApis(pd, smallWechatAttrDto, ServiceCodeSmallWeChatConstant.LIST_SMALL_WE_CHATS, SmallWechatAttrDto.class);
+
+        smallWeChatDto.setSmallWechatAttrs(smallWechatAttrs);
+        return smallWeChatDto;
+    }
+
 
     public RestTemplate getRestTemplate() {
         return restTemplate;