dingxin 6 년 전
부모
커밋
b7098191c6

+ 1
- 3
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/TaUserServiceImpl.java 파일 보기

@@ -361,15 +361,13 @@ public class TaUserServiceImpl implements ITaUserService {
361 361
             int VerifyStatus= Integer.parseInt(taUser.getVerifyStatus());
362 362
             int Role= TaSysUserRole.getRoleId();
363 363
             if (1==VerifyStatus &&1==Role) {
364
-                //根据手机号查当前信息
365
-            TpBuildingOwnerInfo tpBuildingOwnerInfoId=tpBuildingOwnerInfoMapper.selectOwnerTel(taUser.getLoginName());          //
366 364
             TpBuildingOwnerInfo TpBuildingOwnerInfo = new TpBuildingOwnerInfo();
367 365
             TpBuildingOwnerInfo.setOwnerName(user.getUserName());
368 366
             TpBuildingOwnerInfo.setGender(user.getGender());
369 367
             TpBuildingOwnerInfo.setOwnerTel(user.getLoginName());
370 368
             TpBuildingOwnerInfo.setUpdateDate(new Date());
371 369
             TpBuildingOwnerInfo.setUpdateUser(taUser.getId());
372
-            TpBuildingOwnerInfo.setId(tpBuildingOwnerInfoId.getId());
370
+            TpBuildingOwnerInfo.setId(taUser.getBuildingOwnerInfoId());
373 371
             tpBuildingOwnerInfoMapper.updateByPrimaryKeySelective(TpBuildingOwnerInfo);
374 372
         }
375 373
         if (result > 0){

+ 40
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/constant/RequestURI.java 파일 보기

@@ -0,0 +1,40 @@
1
+package com.community.huiju.constant;
2
+
3
+/**
4
+ * 请求定义
5
+ * @author weiximei
6
+ */
7
+public enum RequestURI {
8
+
9
+    APP_API("/app-api", "APP端请求路径"),
10
+
11
+    OPERATE_API("/operate-api", "运营端请求路径"),
12
+
13
+    PROPERTY_API("/property-api", "物业端请求路径");
14
+
15
+
16
+    RequestURI(String url, String comment) {
17
+        this.url = url;
18
+        this.comment = comment;
19
+    }
20
+
21
+    private String url;
22
+
23
+    private String comment;
24
+
25
+    public String getUrl() {
26
+        return url;
27
+    }
28
+
29
+    public void setUrl(String url) {
30
+        this.url = url;
31
+    }
32
+
33
+    public String getComment() {
34
+        return comment;
35
+    }
36
+
37
+    public void setComment(String comment) {
38
+        this.comment = comment;
39
+    }
40
+}

+ 15
- 10
CODE/smart-community/zuul/src/main/java/com/community/huiju/filter/DomainZuulPostFilter.java 파일 보기

@@ -5,15 +5,15 @@ import com.community.commom.constant.Constant;
5 5
 import com.community.commom.mode.ResponseBean;
6 6
 import com.community.commom.session.UserElement;
7 7
 import com.community.huiju.constant.Header;
8
+import com.community.huiju.constant.RequestURI;
8 9
 import com.community.huiju.constant.Status;
9 10
 import com.netflix.zuul.ZuulFilter;
10 11
 import com.netflix.zuul.context.RequestContext;
11 12
 import com.netflix.zuul.exception.ZuulException;
12 13
 import lombok.extern.slf4j.Slf4j;
13 14
 import org.apache.commons.lang.StringUtils;
14
-import org.springframework.http.HttpMethod;
15
-import org.springframework.http.MediaType;
16 15
 import org.springframework.stereotype.Component;
16
+import org.springframework.util.AntPathMatcher;
17 17
 
18 18
 import javax.servlet.http.HttpServletRequest;
19 19
 import javax.servlet.http.HttpServletResponse;
@@ -26,9 +26,11 @@ import javax.servlet.http.HttpServletResponse;
26 26
 @Slf4j
27 27
 public class DomainZuulPostFilter extends ZuulFilter {
28 28
 
29
+    private AntPathMatcher matcher = new AntPathMatcher();
30
+
29 31
     @Override
30 32
     public String filterType() {
31
-        return "post";
33
+        return "pre";
32 34
     }
33 35
 
34 36
     @Override
@@ -54,30 +56,33 @@ public class DomainZuulPostFilter extends ZuulFilter {
54 56
         response.setContentType("application/json;charset=UTF-8");
55 57
         HttpServletRequest request = ctx.getRequest();
56 58
         String token = request.getHeader(Header.REQUEST_X_AUTH_TOKEN.getValue());
57
-        String loginType = request.getHeader(Header.LOGIN_TYPE.getValue());
59
+        // String loginType = request.getHeader(Header.LOGIN_TYPE.getValue());
60
+        // 根据URL判断是访问哪一个端
61
+        String requestURI = request.getRequestURI();
62
+        ResponseBean responseBean = new ResponseBean();
63
+
58 64
         if (StringUtils.isBlank(token)) {
59 65
 
60 66
         }else {
61 67
             log.info("获取的token: {}", token);
62
-            ResponseBean responseBean = new ResponseBean();
63
-            // APP 端
64
-            if (Constant.APP_LOGIN_TYPE.equals(loginType.trim())){
68
+
69
+            if (matcher.match(RequestURI.APP_API.getUrl(), requestURI)) {
65 70
                 UserElement appElement = (UserElement) request.getSession().getAttribute(Constant.APP_USER_SESSION);
66 71
                 if (null == appElement) {
67 72
                     responseBean.addError(Status.RESPONSE_STATUS_803.getValue(),Status.RESPONSE_STATUS_803.getComment());
73
+                    ctx.setSendZuulResponse(false);
68 74
                     ctx.setResponseBody(JSONObject.toJSONString(responseBean));
69 75
                 }
70 76
 
71
-                // WEB 端
72
-            } else {
77
+            } else if (matcher.match(RequestURI.OPERATE_API.getUrl(), requestURI) || matcher.match(RequestURI.PROPERTY_API.getUrl(), requestURI)) {
73 78
                 UserElement webOperateElement = (UserElement) request.getSession().getAttribute(Constant.WEB_USER_SESSION);
74 79
                 if (null == webOperateElement) {
75 80
                     responseBean.addError(Status.RESPONSE_STATUS_803.getValue(),Status.RESPONSE_STATUS_803.getComment());
81
+                    ctx.setSendZuulResponse(false);
76 82
                     ctx.setResponseBody(JSONObject.toJSONString(responseBean));
77 83
                 }
78 84
             }
79 85
 
80
-
81 86
         }
82 87
 
83 88
         return null;