瀏覽代碼

zuul 网关层 权限处理,还存问题,未开放

weiximei 6 年之前
父節點
當前提交
492bd48765
共有 51 個文件被更改,包括 2750 次插入4 次删除
  1. 2
    2
      CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/CodeController.java
  2. 3
    0
      CODE/smart-community/app-api/src/main/java/com/community/huiju/dao/TaSysRoleMapper.java
  3. 6
    0
      CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/TaUserServiceImpl.java
  4. 9
    0
      CODE/smart-community/community-common/src/main/java/com/community/commom/constant/Constant.java
  5. 二進制
      CODE/smart-community/community-common/target/classes/com/community/commom/constant/Constant.class
  6. 42
    0
      CODE/smart-community/zuul/pom.xml
  7. 2
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/ZuulApplication.java
  8. 45
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/constant/Header.java
  9. 23
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/constant/SecurityParametes.java
  10. 52
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/constant/Status.java
  11. 31
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/dao/TaSysRoleMapper.java
  12. 22
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/dao/TaSysUserRoleMapper.java
  13. 50
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/dao/TaUserMapper.java
  14. 19
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/dao/ToSysMenuMapper.java
  15. 28
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/dao/ToSysRoleMapper.java
  16. 19
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/dao/ToSysRoleMenuMapper.java
  17. 21
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/dao/ToSysUserRoleMapper.java
  18. 19
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/dao/ToUserMapper.java
  19. 18
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/dto/MenuDTO.java
  20. 36
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/dto/RoleDTO.java
  21. 18
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/exception/WisdomSecurityException.java
  22. 75
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/model/TaSysRole.java
  23. 43
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/model/TaSysUserRole.java
  24. 185
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/model/TaUser.java
  25. 83
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/model/ToSysMenu.java
  26. 85
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/model/ToSysRole.java
  27. 33
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/model/ToSysRoleMenu.java
  28. 33
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/model/ToSysUserRole.java
  29. 125
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/model/ToUser.java
  30. 55
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/security/RestAuthenticationEntryPoint.java
  31. 30
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/security/RestPreAuthenticateManager.java
  32. 45
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/security/RestPreAuthenticateProvider.java
  33. 160
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/security/RestPreAuthenticatedProcessingFilter.java
  34. 30
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/security/TokenAuthrentication.java
  35. 94
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/security/WisdomSecurityConfig.java
  36. 22
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/service/IRoleService.java
  37. 10
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/service/IUserService.java
  38. 59
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/service/impl/RoleService.java
  39. 16
    0
      CODE/smart-community/zuul/src/main/java/com/community/huiju/service/impl/UserService.java
  40. 3
    1
      CODE/smart-community/zuul/src/main/resources/application.yml
  41. 7
    0
      CODE/smart-community/zuul/src/main/resources/bootstrap.yml
  42. 13
    1
      CODE/smart-community/zuul/src/main/resources/log4j.properties
  43. 130
    0
      CODE/smart-community/zuul/src/main/resources/mapper/TaSysRoleMapper.xml
  44. 89
    0
      CODE/smart-community/zuul/src/main/resources/mapper/TaSysUserRoleMapper.xml
  45. 276
    0
      CODE/smart-community/zuul/src/main/resources/mapper/TaUserMapper.xml
  46. 128
    0
      CODE/smart-community/zuul/src/main/resources/mapper/ToSysMenuMapper.xml
  47. 135
    0
      CODE/smart-community/zuul/src/main/resources/mapper/ToSysRoleMapper.xml
  48. 71
    0
      CODE/smart-community/zuul/src/main/resources/mapper/ToSysRoleMenuMapper.xml
  49. 71
    0
      CODE/smart-community/zuul/src/main/resources/mapper/ToSysUserRoleMapper.xml
  50. 177
    0
      CODE/smart-community/zuul/src/main/resources/mapper/ToUserMapper.xml
  51. 2
    0
      CODE/smart-community/zuul/src/main/resources/parametes.properties

+ 2
- 2
CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/CodeController.java 查看文件

@@ -40,8 +40,8 @@ public class CodeController {
40 40
     public ResponseBean sendCode(@RequestParam String phone, HttpSession session) {
41 41
         ResponseBean response = new ResponseBean();
42 42
         int code = (int) ((Math.random()*9+1)*1000);
43
-        //boolean result = iCode.sendCode(phone,String.valueOf(code));
44
-        boolean result = true;
43
+        boolean result = iCode.sendCode(phone,String.valueOf(code));
44
+        //boolean result = true;
45 45
         if (result) {
46 46
             log.info("{} 验证码: {}",phone,code);
47 47
             // 设置缓存

+ 3
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/dao/TaSysRoleMapper.java 查看文件

@@ -4,6 +4,8 @@ package com.community.huiju.dao;
4 4
 import com.community.huiju.model.TaSysRole;
5 5
 import org.apache.ibatis.annotations.Mapper;
6 6
 
7
+import java.util.List;
8
+
7 9
 @Mapper
8 10
 public interface TaSysRoleMapper {
9 11
     int deleteByPrimaryKey(Integer id);
@@ -19,4 +21,5 @@ public interface TaSysRoleMapper {
19 21
     int updateByPrimaryKey(TaSysRole record);
20 22
 
21 23
     TaSysRole findRoleByUserId(Integer userId);
24
+
22 25
 }

+ 6
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/TaUserServiceImpl.java 查看文件

@@ -287,6 +287,12 @@ public class TaUserServiceImpl implements ITaUserService {
287 287
             response.addError("对不起,您未认证或认证已作废!");
288 288
             return response;
289 289
         }
290
+        // 当前用户的身份
291
+        TaSysRole role = taSysRoleMapper.findRoleByUserId(taUser.getId());
292
+        if (!"OWNER".equals(role.getRoleName())) {
293
+            response.addError("对不起,您不是业主,不能添加家属或租客!");
294
+            return response;
295
+        }
290 296
 
291 297
         TaUser user = new TaUser();
292 298
         user.setUserName(userName);

+ 9
- 0
CODE/smart-community/community-common/src/main/java/com/community/commom/constant/Constant.java 查看文件

@@ -12,6 +12,15 @@ public class Constant {
12 12
     /** WEB端session **/
13 13
     public static final String WEB_USER_SESSION = "webUser";
14 14
 
15
+    /** 不需要权限的URL身份 **/
16
+    public static final String ROLE_NONE = "ROLE_NONEUSER";
17
+
18
+    /** app登陆类型 **/
19
+    public static final String APP_LOGIN_TYPE = "app";
20
+
21
+    /** web登陆类型 **/
22
+    public static final String WEB_LOGIN_TYPE = "web";
23
+
15 24
     /** 手机验证码 **/
16 25
     public static final String SESSION_PHONE_CODE = "phone_code";
17 26
 

二進制
CODE/smart-community/community-common/target/classes/com/community/commom/constant/Constant.class 查看文件


+ 42
- 0
CODE/smart-community/zuul/pom.xml 查看文件

@@ -26,6 +26,7 @@
26 26
 		<logback.version>1.1.6</logback.version>
27 27
 		<logback.access.version>1.1.2</logback.access.version>
28 28
 		<commons.logging.version>1.2</commons.logging.version>
29
+		<spring-security.version>5.1.0.RELEASE</spring-security.version>
29 30
 	</properties>
30 31
 
31 32
 	<dependencies>
@@ -111,6 +112,47 @@
111 112
             <version>${commons.logging.version}</version>
112 113
         </dependency>
113 114
 
115
+		<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-core -->
116
+		<dependency>
117
+			<groupId>org.springframework.security</groupId>
118
+			<artifactId>spring-security-core</artifactId>
119
+			<version>${spring-security.version}</version>
120
+		</dependency>
121
+		<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-web -->
122
+		<dependency>
123
+			<groupId>org.springframework.security</groupId>
124
+			<artifactId>spring-security-web</artifactId>
125
+			<version>${spring-security.version}</version>
126
+		</dependency>
127
+
128
+		<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-config -->
129
+		<dependency>
130
+			<groupId>org.springframework.security</groupId>
131
+			<artifactId>spring-security-config</artifactId>
132
+			<version>${spring-security.version}</version>
133
+		</dependency>
134
+
135
+		<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
136
+		<dependency>
137
+			<groupId>com.alibaba</groupId>
138
+			<artifactId>fastjson</artifactId>
139
+			<version>1.2.51</version>
140
+		</dependency>
141
+
142
+		<!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter -->
143
+		<dependency>
144
+			<groupId>org.mybatis.spring.boot</groupId>
145
+			<artifactId>mybatis-spring-boot-starter</artifactId>
146
+			<version>1.3.2</version>
147
+		</dependency>
148
+
149
+		<dependency>
150
+			<groupId>com.community</groupId>
151
+			<artifactId>community-common</artifactId>
152
+			<version>0.0.1</version>
153
+			<scope>compile</scope>
154
+		</dependency>
155
+
114 156
 	</dependencies>
115 157
 
116 158
 	<dependencyManagement>

+ 2
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/ZuulApplication.java 查看文件

@@ -5,11 +5,13 @@ import org.springframework.boot.SpringApplication;
5 5
 import org.springframework.cloud.client.SpringCloudApplication;
6 6
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
7 7
 import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
8
+import org.springframework.context.annotation.PropertySource;
8 9
 
9 10
 @EnableZuulProxy
10 11
 @EnableDiscoveryClient
11 12
 @SpringCloudApplication
12 13
 @EnableSwaggerButler
14
+@PropertySource(value = "classpath:parametes.properties")
13 15
 public class ZuulApplication {
14 16
 
15 17
 	public static void main(String[] args) {

+ 45
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/constant/Header.java 查看文件

@@ -0,0 +1,45 @@
1
+package com.community.huiju.constant;
2
+
3
+public enum  Header {
4
+
5
+    /** header start **/
6
+    REQUEST_X_AUTH_TOKEN("X-Auth-Token","token"),
7
+
8
+    REQUEST_VERSION("Version","版本"),
9
+
10
+    HEADER_ERROR("Header-Error","头部错误标记"),
11
+
12
+    LOGIN_TYPE("Login-Type","登陆类型"),
13
+    /** header end **/
14
+
15
+    ;
16
+
17
+    private String value;
18
+
19
+    private String comment;
20
+
21
+    Header(String value, String comment) {
22
+        this.value = value;
23
+        this.comment = comment;
24
+    }
25
+
26
+    Header() {
27
+    }
28
+
29
+    public String getValue() {
30
+        return value;
31
+    }
32
+
33
+    public void setValue(String value) {
34
+        this.value = value;
35
+    }
36
+
37
+    public String getComment() {
38
+        return comment;
39
+    }
40
+
41
+    public void setComment(String comment) {
42
+        this.comment = comment;
43
+    }
44
+
45
+}

+ 23
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/constant/SecurityParametes.java 查看文件

@@ -0,0 +1,23 @@
1
+package com.community.huiju.constant;
2
+
3
+import lombok.Data;
4
+import org.springframework.beans.factory.annotation.Value;
5
+import org.springframework.stereotype.Component;
6
+
7
+import java.util.List;
8
+
9
+/**
10
+ * 系统参数
11
+ * @author weixmei
12
+ */
13
+@Data
14
+@Component
15
+public class SecurityParametes {
16
+
17
+    @Value("#{'${security.noneSercurityPath}'.split(',')}")
18
+    private List<String> noneSercurityPath;
19
+
20
+    @Value("#{'${security.appSercurityPath}'.split(',')}")
21
+    private List<String> appSercurityPath;
22
+
23
+}

+ 52
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/constant/Status.java 查看文件

@@ -0,0 +1,52 @@
1
+package com.community.huiju.constant;
2
+
3
+public enum Status {
4
+
5
+    /** 状态码 start**/
6
+    RESPONSE_STATUS_200("200","请求成功!"),
7
+
8
+    RESPONSE_STATUS_400("400","请求无法被理解!"),
9
+
10
+    RESPONSE_STATUS_401("401","无访问权限!"),
11
+
12
+    RESPONSE_STATUS_500("500","服务器错误!"),
13
+
14
+    RESPONSE_STATUS_800("800","APP版本过低!"),
15
+
16
+    RESPONSE_STATUS_801("801","无法确定用户类型!"),
17
+
18
+    RESPONSE_STATUS_802("802","身份凭证不存在!"),
19
+
20
+    RESPONSE_STATUS_803("803","Token已过期!"),
21
+    /** 状态码 end **/
22
+
23
+    ;
24
+
25
+    private String value;
26
+
27
+    private String comment;
28
+
29
+    Status(String value, String comment) {
30
+        this.value = value;
31
+        this.comment = comment;
32
+    }
33
+
34
+    Status() {
35
+    }
36
+
37
+    public String getValue() {
38
+        return value;
39
+    }
40
+
41
+    public void setValue(String value) {
42
+        this.value = value;
43
+    }
44
+
45
+    public String getComment() {
46
+        return comment;
47
+    }
48
+
49
+    public void setComment(String comment) {
50
+        this.comment = comment;
51
+    }
52
+}

+ 31
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/dao/TaSysRoleMapper.java 查看文件

@@ -0,0 +1,31 @@
1
+package com.community.huiju.dao;
2
+
3
+
4
+import com.community.huiju.model.TaSysRole;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+import java.util.List;
8
+
9
+@Mapper
10
+public interface TaSysRoleMapper {
11
+    int deleteByPrimaryKey(Integer id);
12
+
13
+    int insert(TaSysRole record);
14
+
15
+    int insertSelective(TaSysRole record);
16
+
17
+    TaSysRole selectByPrimaryKey(Integer id);
18
+
19
+    int updateByPrimaryKeySelective(TaSysRole record);
20
+
21
+    int updateByPrimaryKey(TaSysRole record);
22
+
23
+    TaSysRole findRoleByUserId(Integer userId);
24
+
25
+    /**
26
+     * 根据用户ID查询所有角色
27
+     * @param userId
28
+     * @return
29
+     */
30
+    List<TaSysRole> selectRoleByUserId(Integer userId);
31
+}

+ 22
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/dao/TaSysUserRoleMapper.java 查看文件

@@ -0,0 +1,22 @@
1
+package com.community.huiju.dao;
2
+
3
+
4
+import com.community.huiju.model.TaSysUserRole;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+@Mapper
8
+public interface TaSysUserRoleMapper {
9
+    int deleteByPrimaryKey(Integer id);
10
+
11
+    int insert(TaSysUserRole record);
12
+
13
+    int insertSelective(TaSysUserRole record);
14
+
15
+    TaSysUserRole selectByPrimaryKey(Integer id);
16
+
17
+    int updateByPrimaryKeySelective(TaSysUserRole record);
18
+
19
+    int updateByPrimaryKey(TaSysUserRole record);
20
+
21
+    Integer findSysUserRoleByUserIdAndRoleId(Integer userId);
22
+}

+ 50
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/dao/TaUserMapper.java 查看文件

@@ -0,0 +1,50 @@
1
+package com.community.huiju.dao;
2
+
3
+import com.community.huiju.model.TaUser;
4
+import org.apache.ibatis.annotations.Mapper;
5
+
6
+import java.util.List;
7
+import java.util.Map;
8
+
9
+@Mapper
10
+public interface TaUserMapper {
11
+    int deleteByPrimaryKey(Integer id);
12
+
13
+    int insert(TaUser record);
14
+
15
+    int insertSelective(TaUser record);
16
+
17
+    TaUser selectByPrimaryKey(Integer id);
18
+
19
+    int updateByPrimaryKeySelective(TaUser record);
20
+
21
+    int updateByPrimaryKey(TaUser record);
22
+
23
+    /**
24
+     * 根据loginName和loginPassword 查询用户
25
+     * @param map
26
+     * @return 用户
27
+     */
28
+    TaUser selectByLoginNameAndByLoginPassword(Map<String, Object> map);
29
+
30
+    /**
31
+     * 根据loginName 查询用户
32
+     * @param map
33
+     * @return 用户
34
+     */
35
+    TaUser selectByLoginName(Map<String, Object> map);
36
+
37
+    /**
38
+     * 更新当前用户电话
39
+     * @param record
40
+     * @return
41
+     */
42
+    TaUser ubdateLongName(TaUser record);
43
+
44
+    /**
45
+     * 查询房屋成员列表
46
+     * @param parentId
47
+     * @return
48
+     */
49
+    List<TaUser> selectUserListByParentId(Integer parentId);
50
+}

+ 19
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/dao/ToSysMenuMapper.java 查看文件

@@ -0,0 +1,19 @@
1
+package com.community.huiju.dao;
2
+
3
+import com.community.huiju.model.ToSysMenu;
4
+import org.apache.ibatis.annotations.Mapper;
5
+
6
+@Mapper
7
+public interface ToSysMenuMapper {
8
+    int deleteByPrimaryKey(Integer id);
9
+
10
+    int insert(ToSysMenu record);
11
+
12
+    int insertSelective(ToSysMenu record);
13
+
14
+    ToSysMenu selectByPrimaryKey(Integer id);
15
+
16
+    int updateByPrimaryKeySelective(ToSysMenu record);
17
+
18
+    int updateByPrimaryKey(ToSysMenu record);
19
+}

+ 28
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/dao/ToSysRoleMapper.java 查看文件

@@ -0,0 +1,28 @@
1
+package com.community.huiju.dao;
2
+
3
+import com.community.huiju.model.ToSysRole;
4
+import org.apache.ibatis.annotations.Mapper;
5
+
6
+import java.util.List;
7
+
8
+@Mapper
9
+public interface ToSysRoleMapper {
10
+    int deleteByPrimaryKey(Integer id);
11
+
12
+    int insert(ToSysRole record);
13
+
14
+    int insertSelective(ToSysRole record);
15
+
16
+    ToSysRole selectByPrimaryKey(Integer id);
17
+
18
+    int updateByPrimaryKeySelective(ToSysRole record);
19
+
20
+    int updateByPrimaryKey(ToSysRole record);
21
+
22
+    /**
23
+     * 根据用户ID查询所有角色
24
+     * @param userId
25
+     * @return
26
+     */
27
+    List<ToSysRole> selectRoleByUserId(Integer userId);
28
+}

+ 19
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/dao/ToSysRoleMenuMapper.java 查看文件

@@ -0,0 +1,19 @@
1
+package com.community.huiju.dao;
2
+
3
+import com.community.huiju.model.ToSysRoleMenu;
4
+import org.apache.ibatis.annotations.Mapper;
5
+
6
+@Mapper
7
+public interface ToSysRoleMenuMapper {
8
+    int deleteByPrimaryKey(Integer id);
9
+
10
+    int insert(ToSysRoleMenu record);
11
+
12
+    int insertSelective(ToSysRoleMenu record);
13
+
14
+    ToSysRoleMenu selectByPrimaryKey(Integer id);
15
+
16
+    int updateByPrimaryKeySelective(ToSysRoleMenu record);
17
+
18
+    int updateByPrimaryKey(ToSysRoleMenu record);
19
+}

+ 21
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/dao/ToSysUserRoleMapper.java 查看文件

@@ -0,0 +1,21 @@
1
+package com.community.huiju.dao;
2
+
3
+import com.community.huiju.model.ToSysUserRole;
4
+import org.apache.ibatis.annotations.Mapper;
5
+
6
+@Mapper
7
+public interface ToSysUserRoleMapper {
8
+    int deleteByPrimaryKey(Integer id);
9
+
10
+    int insert(ToSysUserRole record);
11
+
12
+    int insertSelective(ToSysUserRole record);
13
+
14
+    ToSysUserRole selectByPrimaryKey(Integer id);
15
+
16
+    int updateByPrimaryKeySelective(ToSysUserRole record);
17
+
18
+    int updateByPrimaryKey(ToSysUserRole record);
19
+
20
+
21
+}

+ 19
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/dao/ToUserMapper.java 查看文件

@@ -0,0 +1,19 @@
1
+package com.community.huiju.dao;
2
+
3
+import com.community.huiju.model.ToUser;
4
+import org.apache.ibatis.annotations.Mapper;
5
+
6
+@Mapper
7
+public interface ToUserMapper {
8
+    int deleteByPrimaryKey(Integer id);
9
+
10
+    int insert(ToUser record);
11
+
12
+    int insertSelective(ToUser record);
13
+
14
+    ToUser selectByPrimaryKey(Integer id);
15
+
16
+    int updateByPrimaryKeySelective(ToUser record);
17
+
18
+    int updateByPrimaryKey(ToUser record);
19
+}

+ 18
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/dto/MenuDTO.java 查看文件

@@ -0,0 +1,18 @@
1
+package com.community.huiju.dto;
2
+
3
+/**
4
+ * 菜单
5
+ * @author weiximei
6
+ */
7
+public class MenuDTO {
8
+
9
+    private String menuUrl;
10
+
11
+    public String getMenuUrl() {
12
+        return menuUrl;
13
+    }
14
+
15
+    public void setMenuUrl(String menuUrl) {
16
+        this.menuUrl = menuUrl;
17
+    }
18
+}

+ 36
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/dto/RoleDTO.java 查看文件

@@ -0,0 +1,36 @@
1
+package com.community.huiju.dto;
2
+
3
+/**
4
+ * 角色
5
+ * @author weiximei
6
+ */
7
+public class RoleDTO {
8
+
9
+    private Integer id;
10
+
11
+    private String roleName;
12
+
13
+    public RoleDTO(Integer id, String roleName) {
14
+        this.id = id;
15
+        this.roleName = roleName;
16
+    }
17
+
18
+    public RoleDTO() {
19
+    }
20
+
21
+    public Integer getId() {
22
+        return id;
23
+    }
24
+
25
+    public void setId(Integer id) {
26
+        this.id = id;
27
+    }
28
+
29
+    public String getRoleName() {
30
+        return roleName;
31
+    }
32
+
33
+    public void setRoleName(String roleName) {
34
+        this.roleName = roleName;
35
+    }
36
+}

+ 18
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/exception/WisdomSecurityException.java 查看文件

@@ -0,0 +1,18 @@
1
+package com.community.huiju.exception;
2
+
3
+import org.springframework.security.core.AuthenticationException;
4
+
5
+/**
6
+ * @author weiximei
7
+ */
8
+public class WisdomSecurityException extends AuthenticationException {
9
+
10
+
11
+    public WisdomSecurityException(String msg, Throwable t) {
12
+        super(msg, t);
13
+    }
14
+
15
+    public WisdomSecurityException(String msg) {
16
+        super(msg);
17
+    }
18
+}

+ 75
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/model/TaSysRole.java 查看文件

@@ -0,0 +1,75 @@
1
+package com.community.huiju.model;
2
+
3
+import java.util.Date;
4
+
5
+public class TaSysRole {
6
+    private Integer id;
7
+
8
+    private String roleName;
9
+
10
+    private String description;
11
+
12
+    private Integer createUser;
13
+
14
+    private Date createDate;
15
+
16
+    private Integer updateUser;
17
+
18
+    private Date updateDate;
19
+
20
+    public Integer getId() {
21
+        return id;
22
+    }
23
+
24
+    public void setId(Integer id) {
25
+        this.id = id;
26
+    }
27
+
28
+    public String getRoleName() {
29
+        return roleName;
30
+    }
31
+
32
+    public void setRoleName(String roleName) {
33
+        this.roleName = roleName == null ? null : roleName.trim();
34
+    }
35
+
36
+    public String getDescription() {
37
+        return description;
38
+    }
39
+
40
+    public void setDescription(String description) {
41
+        this.description = description == null ? null : description.trim();
42
+    }
43
+
44
+    public Integer getCreateUser() {
45
+        return createUser;
46
+    }
47
+
48
+    public void setCreateUser(Integer createUser) {
49
+        this.createUser = createUser;
50
+    }
51
+
52
+    public Date getCreateDate() {
53
+        return createDate;
54
+    }
55
+
56
+    public void setCreateDate(Date createDate) {
57
+        this.createDate = createDate;
58
+    }
59
+
60
+    public Integer getUpdateUser() {
61
+        return updateUser;
62
+    }
63
+
64
+    public void setUpdateUser(Integer updateUser) {
65
+        this.updateUser = updateUser;
66
+    }
67
+
68
+    public Date getUpdateDate() {
69
+        return updateDate;
70
+    }
71
+
72
+    public void setUpdateDate(Date updateDate) {
73
+        this.updateDate = updateDate;
74
+    }
75
+}

+ 43
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/model/TaSysUserRole.java 查看文件

@@ -0,0 +1,43 @@
1
+package com.community.huiju.model;
2
+
3
+public class TaSysUserRole {
4
+    private Integer id;
5
+
6
+    private Integer communityId;
7
+
8
+    private Integer userId;
9
+
10
+    private Integer roleId;
11
+
12
+    public Integer getId() {
13
+        return id;
14
+    }
15
+
16
+    public void setId(Integer id) {
17
+        this.id = id;
18
+    }
19
+
20
+    public Integer getCommunityId() {
21
+        return communityId;
22
+    }
23
+
24
+    public void setCommunityId(Integer communityId) {
25
+        this.communityId = communityId;
26
+    }
27
+
28
+    public Integer getUserId() {
29
+        return userId;
30
+    }
31
+
32
+    public void setUserId(Integer userId) {
33
+        this.userId = userId;
34
+    }
35
+
36
+    public Integer getRoleId() {
37
+        return roleId;
38
+    }
39
+
40
+    public void setRoleId(Integer roleId) {
41
+        this.roleId = roleId;
42
+    }
43
+}

+ 185
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/model/TaUser.java 查看文件

@@ -0,0 +1,185 @@
1
+package com.community.huiju.model;
2
+
3
+import java.util.Date;
4
+
5
+public class TaUser {
6
+    private Integer id;
7
+
8
+    private Integer communityId;
9
+
10
+    private Integer buildingOwnerInfoId;
11
+
12
+    private String headPortrait;
13
+
14
+    private String userName;
15
+
16
+    private String loginName;
17
+
18
+    private String loginPassword;
19
+
20
+    private String email;
21
+
22
+    private String gender;
23
+
24
+    private String status;
25
+
26
+    private String remark;
27
+
28
+    private Integer parentId;
29
+
30
+    private String acceptAgreementStatus;
31
+
32
+    private String verifyStatus;
33
+
34
+    private Integer createUser;
35
+
36
+    private Date createDate;
37
+
38
+    private Integer updateUser;
39
+
40
+    private Date updateDate;
41
+
42
+    public Integer getId() {
43
+        return id;
44
+    }
45
+
46
+    public void setId(Integer id) {
47
+        this.id = id;
48
+    }
49
+
50
+    public Integer getCommunityId() {
51
+        return communityId;
52
+    }
53
+
54
+    public void setCommunityId(Integer communityId) {
55
+        this.communityId = communityId;
56
+    }
57
+
58
+    public Integer getBuildingOwnerInfoId() {
59
+        return buildingOwnerInfoId;
60
+    }
61
+
62
+    public void setBuildingOwnerInfoId(Integer buildingOwnerInfoId) {
63
+        this.buildingOwnerInfoId = buildingOwnerInfoId;
64
+    }
65
+
66
+    public String getHeadPortrait() {
67
+        return headPortrait;
68
+    }
69
+
70
+    public void setHeadPortrait(String headPortrait) {
71
+        this.headPortrait = headPortrait == null ? null : headPortrait.trim();
72
+    }
73
+
74
+    public String getUserName() {
75
+        return userName;
76
+    }
77
+
78
+    public void setUserName(String userName) {
79
+        this.userName = userName == null ? null : userName.trim();
80
+    }
81
+
82
+    public String getLoginName() {
83
+        return loginName;
84
+    }
85
+
86
+    public void setLoginName(String loginName) {
87
+        this.loginName = loginName == null ? null : loginName.trim();
88
+    }
89
+
90
+    public String getLoginPassword() {
91
+        return loginPassword;
92
+    }
93
+
94
+    public void setLoginPassword(String loginPassword) {
95
+        this.loginPassword = loginPassword == null ? null : loginPassword.trim();
96
+    }
97
+
98
+    public String getEmail() {
99
+        return email;
100
+    }
101
+
102
+    public void setEmail(String email) {
103
+        this.email = email == null ? null : email.trim();
104
+    }
105
+
106
+    public String getGender() {
107
+        return gender;
108
+    }
109
+
110
+    public void setGender(String gender) {
111
+        this.gender = gender == null ? null : gender.trim();
112
+    }
113
+
114
+    public String getStatus() {
115
+        return status;
116
+    }
117
+
118
+    public void setStatus(String status) {
119
+        this.status = status == null ? null : status.trim();
120
+    }
121
+
122
+    public String getRemark() {
123
+        return remark;
124
+    }
125
+
126
+    public void setRemark(String remark) {
127
+        this.remark = remark == null ? null : remark.trim();
128
+    }
129
+
130
+    public Integer getParentId() {
131
+        return parentId;
132
+    }
133
+
134
+    public void setParentId(Integer parentId) {
135
+        this.parentId = parentId;
136
+    }
137
+
138
+    public String getAcceptAgreementStatus() {
139
+        return acceptAgreementStatus;
140
+    }
141
+
142
+    public void setAcceptAgreementStatus(String acceptAgreementStatus) {
143
+        this.acceptAgreementStatus = acceptAgreementStatus == null ? null : acceptAgreementStatus.trim();
144
+    }
145
+
146
+    public String getVerifyStatus() {
147
+        return verifyStatus;
148
+    }
149
+
150
+    public void setVerifyStatus(String verifyStatus) {
151
+        this.verifyStatus = verifyStatus == null ? null : verifyStatus.trim();
152
+    }
153
+
154
+    public Integer getCreateUser() {
155
+        return createUser;
156
+    }
157
+
158
+    public void setCreateUser(Integer createUser) {
159
+        this.createUser = createUser;
160
+    }
161
+
162
+    public Date getCreateDate() {
163
+        return createDate;
164
+    }
165
+
166
+    public void setCreateDate(Date createDate) {
167
+        this.createDate = createDate;
168
+    }
169
+
170
+    public Integer getUpdateUser() {
171
+        return updateUser;
172
+    }
173
+
174
+    public void setUpdateUser(Integer updateUser) {
175
+        this.updateUser = updateUser;
176
+    }
177
+
178
+    public Date getUpdateDate() {
179
+        return updateDate;
180
+    }
181
+
182
+    public void setUpdateDate(Date updateDate) {
183
+        this.updateDate = updateDate;
184
+    }
185
+}

+ 83
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/model/ToSysMenu.java 查看文件

@@ -0,0 +1,83 @@
1
+package com.community.huiju.model;
2
+
3
+public class ToSysMenu {
4
+    private Integer id;
5
+
6
+    private String menuName;
7
+
8
+    private String menuUrl;
9
+
10
+    private String menuIcon;
11
+
12
+    private Integer parentId;
13
+
14
+    private Integer sort;
15
+
16
+    private String menuType;
17
+
18
+    private String status;
19
+
20
+    public Integer getId() {
21
+        return id;
22
+    }
23
+
24
+    public void setId(Integer id) {
25
+        this.id = id;
26
+    }
27
+
28
+    public String getMenuName() {
29
+        return menuName;
30
+    }
31
+
32
+    public void setMenuName(String menuName) {
33
+        this.menuName = menuName == null ? null : menuName.trim();
34
+    }
35
+
36
+    public String getMenuUrl() {
37
+        return menuUrl;
38
+    }
39
+
40
+    public void setMenuUrl(String menuUrl) {
41
+        this.menuUrl = menuUrl == null ? null : menuUrl.trim();
42
+    }
43
+
44
+    public String getMenuIcon() {
45
+        return menuIcon;
46
+    }
47
+
48
+    public void setMenuIcon(String menuIcon) {
49
+        this.menuIcon = menuIcon == null ? null : menuIcon.trim();
50
+    }
51
+
52
+    public Integer getParentId() {
53
+        return parentId;
54
+    }
55
+
56
+    public void setParentId(Integer parentId) {
57
+        this.parentId = parentId;
58
+    }
59
+
60
+    public Integer getSort() {
61
+        return sort;
62
+    }
63
+
64
+    public void setSort(Integer sort) {
65
+        this.sort = sort;
66
+    }
67
+
68
+    public String getMenuType() {
69
+        return menuType;
70
+    }
71
+
72
+    public void setMenuType(String menuType) {
73
+        this.menuType = menuType == null ? null : menuType.trim();
74
+    }
75
+
76
+    public String getStatus() {
77
+        return status;
78
+    }
79
+
80
+    public void setStatus(String status) {
81
+        this.status = status == null ? null : status.trim();
82
+    }
83
+}

+ 85
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/model/ToSysRole.java 查看文件

@@ -0,0 +1,85 @@
1
+package com.community.huiju.model;
2
+
3
+import java.util.Date;
4
+
5
+public class ToSysRole {
6
+    private Integer id;
7
+
8
+    private String roleName;
9
+
10
+    private String description;
11
+
12
+    private String status;
13
+
14
+    private Integer createUser;
15
+
16
+    private Date createDate;
17
+
18
+    private Integer updateUser;
19
+
20
+    private Date updateDate;
21
+
22
+    public Integer getId() {
23
+        return id;
24
+    }
25
+
26
+    public void setId(Integer id) {
27
+        this.id = id;
28
+    }
29
+
30
+    public String getRoleName() {
31
+        return roleName;
32
+    }
33
+
34
+    public void setRoleName(String roleName) {
35
+        this.roleName = roleName == null ? null : roleName.trim();
36
+    }
37
+
38
+    public String getDescription() {
39
+        return description;
40
+    }
41
+
42
+    public void setDescription(String description) {
43
+        this.description = description == null ? null : description.trim();
44
+    }
45
+
46
+    public String getStatus() {
47
+        return status;
48
+    }
49
+
50
+    public void setStatus(String status) {
51
+        this.status = status == null ? null : status.trim();
52
+    }
53
+
54
+    public Integer getCreateUser() {
55
+        return createUser;
56
+    }
57
+
58
+    public void setCreateUser(Integer createUser) {
59
+        this.createUser = createUser;
60
+    }
61
+
62
+    public Date getCreateDate() {
63
+        return createDate;
64
+    }
65
+
66
+    public void setCreateDate(Date createDate) {
67
+        this.createDate = createDate;
68
+    }
69
+
70
+    public Integer getUpdateUser() {
71
+        return updateUser;
72
+    }
73
+
74
+    public void setUpdateUser(Integer updateUser) {
75
+        this.updateUser = updateUser;
76
+    }
77
+
78
+    public Date getUpdateDate() {
79
+        return updateDate;
80
+    }
81
+
82
+    public void setUpdateDate(Date updateDate) {
83
+        this.updateDate = updateDate;
84
+    }
85
+}

+ 33
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/model/ToSysRoleMenu.java 查看文件

@@ -0,0 +1,33 @@
1
+package com.community.huiju.model;
2
+
3
+public class ToSysRoleMenu {
4
+    private Integer id;
5
+
6
+    private Integer roleId;
7
+
8
+    private Integer menuId;
9
+
10
+    public Integer getId() {
11
+        return id;
12
+    }
13
+
14
+    public void setId(Integer id) {
15
+        this.id = id;
16
+    }
17
+
18
+    public Integer getRoleId() {
19
+        return roleId;
20
+    }
21
+
22
+    public void setRoleId(Integer roleId) {
23
+        this.roleId = roleId;
24
+    }
25
+
26
+    public Integer getMenuId() {
27
+        return menuId;
28
+    }
29
+
30
+    public void setMenuId(Integer menuId) {
31
+        this.menuId = menuId;
32
+    }
33
+}

+ 33
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/model/ToSysUserRole.java 查看文件

@@ -0,0 +1,33 @@
1
+package com.community.huiju.model;
2
+
3
+public class ToSysUserRole {
4
+    private Integer id;
5
+
6
+    private Integer userId;
7
+
8
+    private Integer roleId;
9
+
10
+    public Integer getId() {
11
+        return id;
12
+    }
13
+
14
+    public void setId(Integer id) {
15
+        this.id = id;
16
+    }
17
+
18
+    public Integer getUserId() {
19
+        return userId;
20
+    }
21
+
22
+    public void setUserId(Integer userId) {
23
+        this.userId = userId;
24
+    }
25
+
26
+    public Integer getRoleId() {
27
+        return roleId;
28
+    }
29
+
30
+    public void setRoleId(Integer roleId) {
31
+        this.roleId = roleId;
32
+    }
33
+}

+ 125
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/model/ToUser.java 查看文件

@@ -0,0 +1,125 @@
1
+package com.community.huiju.model;
2
+
3
+import java.util.Date;
4
+
5
+public class ToUser {
6
+    private Integer id;
7
+
8
+    private String userName;
9
+
10
+    private String loginName;
11
+
12
+    private String loginPassword;
13
+
14
+    private String email;
15
+
16
+    private String headPortrait;
17
+
18
+    private String remark;
19
+
20
+    private String status;
21
+
22
+    private Integer createUser;
23
+
24
+    private Date createDate;
25
+
26
+    private Integer updateUser;
27
+
28
+    private Date updateDate;
29
+
30
+    public Integer getId() {
31
+        return id;
32
+    }
33
+
34
+    public void setId(Integer id) {
35
+        this.id = id;
36
+    }
37
+
38
+    public String getUserName() {
39
+        return userName;
40
+    }
41
+
42
+    public void setUserName(String userName) {
43
+        this.userName = userName == null ? null : userName.trim();
44
+    }
45
+
46
+    public String getLoginName() {
47
+        return loginName;
48
+    }
49
+
50
+    public void setLoginName(String loginName) {
51
+        this.loginName = loginName == null ? null : loginName.trim();
52
+    }
53
+
54
+    public String getLoginPassword() {
55
+        return loginPassword;
56
+    }
57
+
58
+    public void setLoginPassword(String loginPassword) {
59
+        this.loginPassword = loginPassword == null ? null : loginPassword.trim();
60
+    }
61
+
62
+    public String getEmail() {
63
+        return email;
64
+    }
65
+
66
+    public void setEmail(String email) {
67
+        this.email = email == null ? null : email.trim();
68
+    }
69
+
70
+    public String getHeadPortrait() {
71
+        return headPortrait;
72
+    }
73
+
74
+    public void setHeadPortrait(String headPortrait) {
75
+        this.headPortrait = headPortrait == null ? null : headPortrait.trim();
76
+    }
77
+
78
+    public String getRemark() {
79
+        return remark;
80
+    }
81
+
82
+    public void setRemark(String remark) {
83
+        this.remark = remark == null ? null : remark.trim();
84
+    }
85
+
86
+    public String getStatus() {
87
+        return status;
88
+    }
89
+
90
+    public void setStatus(String status) {
91
+        this.status = status == null ? null : status.trim();
92
+    }
93
+
94
+    public Integer getCreateUser() {
95
+        return createUser;
96
+    }
97
+
98
+    public void setCreateUser(Integer createUser) {
99
+        this.createUser = createUser;
100
+    }
101
+
102
+    public Date getCreateDate() {
103
+        return createDate;
104
+    }
105
+
106
+    public void setCreateDate(Date createDate) {
107
+        this.createDate = createDate;
108
+    }
109
+
110
+    public Integer getUpdateUser() {
111
+        return updateUser;
112
+    }
113
+
114
+    public void setUpdateUser(Integer updateUser) {
115
+        this.updateUser = updateUser;
116
+    }
117
+
118
+    public Date getUpdateDate() {
119
+        return updateDate;
120
+    }
121
+
122
+    public void setUpdateDate(Date updateDate) {
123
+        this.updateDate = updateDate;
124
+    }
125
+}

+ 55
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/security/RestAuthenticationEntryPoint.java 查看文件

@@ -0,0 +1,55 @@
1
+package com.community.huiju.security;
2
+
3
+import com.alibaba.fastjson.JSONObject;
4
+import com.community.commom.constant.Constant;
5
+import com.community.commom.mode.ResponseBean;
6
+import com.community.huiju.constant.Header;
7
+import com.community.huiju.constant.Status;
8
+import lombok.extern.slf4j.Slf4j;
9
+import org.apache.commons.lang.StringUtils;
10
+import org.springframework.http.MediaType;
11
+import org.springframework.security.core.AuthenticationException;
12
+import org.springframework.security.web.AuthenticationEntryPoint;
13
+
14
+import javax.servlet.ServletException;
15
+import javax.servlet.http.HttpServletRequest;
16
+import javax.servlet.http.HttpServletResponse;
17
+import java.io.IOException;
18
+
19
+/**
20
+ * 统一出口
21
+ * @author weiximei
22
+ */
23
+@Slf4j
24
+public class RestAuthenticationEntryPoint implements AuthenticationEntryPoint {
25
+
26
+    @Override
27
+    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
28
+        ResponseBean result = new ResponseBean();
29
+        String headerError = (String) request.getAttribute(Header.HEADER_ERROR.getValue());
30
+        if (StringUtils.isNotBlank(headerError)) {
31
+            if (Status.RESPONSE_STATUS_800.getValue().equals(headerError)) {
32
+                result.addError(Status.RESPONSE_STATUS_800.getValue(),Status.RESPONSE_STATUS_800.getComment());
33
+            } else if (Status.RESPONSE_STATUS_801.getValue().equals(headerError)) {
34
+                result.addError("401","请您登陆!");
35
+            }
36
+        }else {
37
+            result.addError("403",Status.RESPONSE_STATUS_401.getComment());
38
+        }
39
+
40
+        try {
41
+            //设置跨域请求 请求结果json刷到响应里
42
+            response.setHeader("Access-Control-Allow-Origin", "*");
43
+            response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, HEADER");
44
+            response.setHeader("Access-Control-Max-Age", "3600");
45
+            response.setHeader("Access-Control-Allow-Headers", "X-Requested-With, user-token, Content-Type, Accept, version, type, platform");
46
+            response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
47
+            response.getWriter().write(JSONObject.toJSONString(result));
48
+            response.flushBuffer();
49
+        } catch (Exception er) {
50
+            log.error("响应错误!",er);
51
+            er.printStackTrace();
52
+        }
53
+
54
+    }
55
+}

+ 30
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/security/RestPreAuthenticateManager.java 查看文件

@@ -0,0 +1,30 @@
1
+package com.community.huiju.security;
2
+
3
+import com.community.huiju.exception.WisdomSecurityException;
4
+import org.springframework.security.authentication.AuthenticationManager;
5
+import org.springframework.security.core.Authentication;
6
+import org.springframework.security.core.AuthenticationException;
7
+import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
8
+import org.springframework.stereotype.Component;
9
+
10
+public class RestPreAuthenticateManager implements AuthenticationManager {
11
+
12
+    @Override
13
+    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
14
+        if (authentication instanceof PreAuthenticatedAuthenticationToken) {
15
+            PreAuthenticatedAuthenticationToken preAuthrentication = (PreAuthenticatedAuthenticationToken) authentication;
16
+            if (null != preAuthrentication.getAuthorities() && preAuthrentication.getAuthorities().size() > 0) {
17
+                preAuthrentication.setAuthenticated(true);
18
+                return preAuthrentication;
19
+            }
20
+        } else if (authentication instanceof  TokenAuthrentication) {
21
+            TokenAuthrentication tokenAuthrentication = (TokenAuthrentication) authentication;
22
+            if (null != tokenAuthrentication.getAuthorities() && tokenAuthrentication.getAuthorities().size() > 0) {
23
+                tokenAuthrentication.setAuthenticated(true);
24
+                return tokenAuthrentication;
25
+            }
26
+        }
27
+
28
+        throw new WisdomSecurityException("没有授权角色!");
29
+    }
30
+}

+ 45
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/security/RestPreAuthenticateProvider.java 查看文件

@@ -0,0 +1,45 @@
1
+package com.community.huiju.security;
2
+
3
+import com.community.huiju.exception.WisdomSecurityException;
4
+import org.springframework.security.authentication.AuthenticationProvider;
5
+import org.springframework.security.core.Authentication;
6
+import org.springframework.security.core.AuthenticationException;
7
+import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
8
+
9
+/**
10
+ * 授权过程
11
+ * @author weiximei
12
+ */
13
+public class RestPreAuthenticateProvider implements AuthenticationProvider {
14
+
15
+    @Override
16
+    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
17
+
18
+        if (authentication instanceof  PreAuthenticatedAuthenticationToken) {
19
+            PreAuthenticatedAuthenticationToken preAuthrentication = (PreAuthenticatedAuthenticationToken) authentication;
20
+            if (null != preAuthrentication.getAuthorities() && preAuthrentication.getAuthorities().size() > 0) {
21
+                preAuthrentication.setAuthenticated(true);
22
+                return preAuthrentication;
23
+            }
24
+        } else if (authentication instanceof  TokenAuthrentication) {
25
+            TokenAuthrentication tokenAuthrentication = (TokenAuthrentication) authentication;
26
+            if (null != tokenAuthrentication.getAuthorities() && tokenAuthrentication.getAuthorities().size() > 0) {
27
+                tokenAuthrentication.setAuthenticated(true);
28
+                return tokenAuthrentication;
29
+            }
30
+        }
31
+
32
+        throw new WisdomSecurityException("没有授权角色!");
33
+    }
34
+
35
+    /**
36
+     * 是否授权过程
37
+     * @param authentication
38
+     * @return
39
+     */
40
+    @Override
41
+    public boolean supports(Class<?> authentication) {
42
+        return PreAuthenticatedAuthenticationToken.class.isAssignableFrom(authentication)
43
+                || TokenAuthrentication.class.isAssignableFrom(authentication);
44
+    }
45
+}

+ 160
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/security/RestPreAuthenticatedProcessingFilter.java 查看文件

@@ -0,0 +1,160 @@
1
+package com.community.huiju.security;
2
+
3
+import com.community.commom.constant.Constant;
4
+import com.community.huiju.config.entity.UserElement;
5
+import com.community.huiju.constant.Header;
6
+import com.community.huiju.constant.Status;
7
+import com.community.huiju.dto.RoleDTO;
8
+import com.community.huiju.service.IRoleService;
9
+import com.google.common.collect.Lists;
10
+import lombok.extern.slf4j.Slf4j;
11
+import org.apache.commons.lang.StringUtils;
12
+import org.springframework.security.core.GrantedAuthority;
13
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
14
+import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter;
15
+import org.springframework.util.AntPathMatcher;
16
+
17
+import javax.servlet.http.HttpServletRequest;
18
+import javax.servlet.http.HttpSession;
19
+import java.util.ArrayList;
20
+import java.util.List;
21
+import java.util.stream.Collectors;
22
+
23
+/**
24
+ * 预授权
25
+ * @author weiximei
26
+ */
27
+@Slf4j
28
+public class RestPreAuthenticatedProcessingFilter extends AbstractPreAuthenticatedProcessingFilter {
29
+
30
+    private AntPathMatcher matcher = new AntPathMatcher();
31
+
32
+    private IRoleService iRoleService;
33
+
34
+
35
+    /** 用户类型请求登陆类型 **/
36
+    private String loginType;
37
+
38
+    /**
39
+     * 不需要权限访问的路径
40
+     */
41
+    private List<String> noneSecurity;
42
+
43
+    /**
44
+     * 获取主体信息
45
+     *
46
+     *      1.验证是否有权限
47
+     *      2.授权
48
+     *
49
+     * @param request
50
+     * @return
51
+     */
52
+    @Override
53
+    protected Object getPreAuthenticatedPrincipal(HttpServletRequest request) {
54
+        List<GrantedAuthority> grantedAuthorityList = new ArrayList<>();
55
+        // 不需要的拦截请求处理
56
+        if (isNoneSecurity(request.getRequestURI().toString()) || "OPTIONS".equals(request.getMethod())){
57
+            GrantedAuthority[] authorities = new GrantedAuthority[1];
58
+            GrantedAuthority roleNone = new SimpleGrantedAuthority(Constant.ROLE_NONE);
59
+            authorities[0]=roleNone;
60
+            grantedAuthorityList.add(authorities[0]);
61
+            return new TokenAuthrentication(grantedAuthorityList);
62
+        }
63
+
64
+        isInspection(request);
65
+
66
+        if (null == request.getAttribute(Header.HEADER_ERROR.getValue())){
67
+            try {
68
+                UserElement userElement = getUserElement(loginType, request);
69
+                List<RoleDTO> roleDTOList = Lists.newArrayList();
70
+                if (Constant.APP_LOGIN_TYPE.equals(loginType)) {
71
+                    roleDTOList = iRoleService.getAppUserRoleByUserId(userElement.getId());
72
+                }else if (Constant.WEB_LOGIN_TYPE.equals(loginType)) {
73
+                    roleDTOList = iRoleService.getWebUserRoleByUserId(userElement.getId());
74
+                }
75
+
76
+                grantedAuthorityList = roleDTOList.stream()
77
+                        .map(e->new SimpleGrantedAuthority("ROLE_OWNER")) //
78
+                        .collect(Collectors.toList());
79
+            } catch (Exception e){
80
+                log.error("用户授权失败!",e);
81
+                e.printStackTrace();
82
+            }
83
+
84
+        }else {
85
+            // 校验有问题后, 需要给个角色, 让流程继续下去
86
+            GrantedAuthority[] authorities = new GrantedAuthority[1];
87
+            GrantedAuthority roleNone = new SimpleGrantedAuthority("ROLE_NONE");
88
+            authorities[0]=roleNone;
89
+            grantedAuthorityList.add(authorities[0]);
90
+        }
91
+
92
+        return new TokenAuthrentication(grantedAuthorityList);
93
+    }
94
+
95
+
96
+    @Override
97
+    protected Object getPreAuthenticatedCredentials(HttpServletRequest httpServletRequest) {
98
+        return null;
99
+    }
100
+
101
+    /**
102
+     * 验证url是否是不需要权限访问
103
+     * @param url
104
+     * @return
105
+     */
106
+    private boolean isNoneSecurity(String url){
107
+        for (String sysMenu : noneSecurity) {
108
+            if (matcher.match(sysMenu,url)){
109
+                return true;
110
+            }
111
+        }
112
+        return false;
113
+    }
114
+
115
+    /**
116
+     * 检验Token, App版本, 用户登录类型
117
+     * @param request
118
+     */
119
+    private void isInspection(HttpServletRequest request){
120
+        // Token检测
121
+        String token = request.getHeader(Header.REQUEST_X_AUTH_TOKEN.getValue());
122
+        if (StringUtils.isBlank(token)) {
123
+            request.setAttribute(Header.HEADER_ERROR.getValue(), Status.RESPONSE_STATUS_802.getValue());
124
+        }
125
+        // APP版本检测
126
+//        String version = request.getHeader(Header.REQUEST_VERSION.getValue());
127
+//        if (StringUtils.isBlank(version)){
128
+//            request.setAttribute(Header.HEADER_ERROR.getValue(),Status.RESPONSE_STATUS_800.getValue());
129
+//        }
130
+        // 用户登陆类型检测
131
+        loginType = ((String) request.getHeader(Header.LOGIN_TYPE.getValue()));
132
+        if (StringUtils.isBlank(loginType)) {
133
+            request.setAttribute(Header.HEADER_ERROR.getValue(), Status.RESPONSE_STATUS_801.getValue());
134
+        }
135
+    }
136
+
137
+
138
+    /**
139
+     * 获取用户session信息
140
+     * @param loginType 用户类型
141
+     * @param request
142
+     * @return
143
+     */
144
+    public UserElement getUserElement(String loginType, HttpServletRequest request){
145
+        HttpSession session = request.getSession();
146
+        UserElement userElement = null;
147
+        if (Constant.APP_LOGIN_TYPE.equals(loginType)) {
148
+            userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
149
+        } else if (Constant.WEB_LOGIN_TYPE.equals(loginType)) {
150
+            userElement = (UserElement) session.getAttribute(Constant.WEB_USER_SESSION);
151
+        }
152
+
153
+        return userElement;
154
+    }
155
+
156
+    public RestPreAuthenticatedProcessingFilter(List<String> noneSecurity,IRoleService iRoleService) {
157
+        this.noneSecurity = noneSecurity;
158
+        this.iRoleService = iRoleService;
159
+    }
160
+}

+ 30
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/security/TokenAuthrentication.java 查看文件

@@ -0,0 +1,30 @@
1
+package com.community.huiju.security;
2
+
3
+import org.springframework.security.authentication.AbstractAuthenticationToken;
4
+import org.springframework.security.core.GrantedAuthority;
5
+
6
+import java.util.Collection;
7
+
8
+/**
9
+ * 认证
10
+ * @author weiximei
11
+ */
12
+public class TokenAuthrentication extends AbstractAuthenticationToken {
13
+
14
+    /**
15
+     * 创建权限集合
16
+     */
17
+    public TokenAuthrentication(Collection<? extends GrantedAuthority> authorities) {
18
+        super(authorities);
19
+    }
20
+
21
+    @Override
22
+    public Object getCredentials() {
23
+        return null;
24
+    }
25
+
26
+    @Override
27
+    public Object getPrincipal() {
28
+        return null;
29
+    }
30
+}

+ 94
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/security/WisdomSecurityConfig.java 查看文件

@@ -0,0 +1,94 @@
1
+package com.community.huiju.security;
2
+
3
+import com.community.huiju.constant.SecurityParametes;
4
+import com.community.huiju.service.IRoleService;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.context.annotation.Configuration;
7
+import org.springframework.http.HttpMethod;
8
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
9
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
10
+import org.springframework.security.config.annotation.web.builders.WebSecurity;
11
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
12
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
13
+import org.springframework.security.config.http.SessionCreationPolicy;
14
+
15
+import java.util.Arrays;
16
+
17
+/**
18
+ * 配置类
19
+ * @author weiximei
20
+ */
21
+//@Configuration
22
+//@EnableWebSecurity
23
+public class WisdomSecurityConfig extends WebSecurityConfigurerAdapter {
24
+
25
+    @Autowired
26
+    private IRoleService iRoleService;
27
+
28
+    @Autowired
29
+    private SecurityParametes parametes;
30
+
31
+    /**
32
+     * 配置预授权
33
+     * @return
34
+     * @throws Exception
35
+     */
36
+    private RestPreAuthenticatedProcessingFilter getPreAuthenticatedProcessingFilter() throws Exception {
37
+        RestPreAuthenticatedProcessingFilter filter = new RestPreAuthenticatedProcessingFilter(parametes.getNoneSercurityPath(),iRoleService);
38
+        //filter.setAuthenticationManager(this.authenticationManagerBean());
39
+        filter.setAuthenticationManager(new RestPreAuthenticateManager());
40
+        return filter;
41
+    }
42
+
43
+    /**
44
+     * user-detail服务
45
+     * @param auth
46
+     * @throws Exception
47
+     */
48
+//    @Override
49
+//    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
50
+//        auth.authenticationProvider(new RestPreAuthenticateProvider());
51
+//        //super.configure(auth);
52
+//    }
53
+
54
+    /**
55
+     * 安全策略
56
+     * @param http
57
+     * @throws Exception
58
+     */
59
+    @Override
60
+    protected void configure(HttpSecurity http) throws Exception {
61
+
62
+        http.csrf().disable();
63
+        http
64
+                .authorizeRequests()
65
+                .antMatchers(parametes.getNoneSercurityPath().toArray(new String[parametes.getNoneSercurityPath().size()])).permitAll() // 不要授权
66
+                .anyRequest()// 任何请求需要授权
67
+                .authenticated() // 需要一个身份
68
+//                .antMatchers(parametes.getAppSercurityPath().get(0).split("=")[1]).hasRole(parametes.getAppSercurityPath().get(0).split("=")[0])
69
+//                .antMatchers(parametes.getAppSercurityPath().get(1).split("=")[1]).hasRole(parametes.getAppSercurityPath().get(1).split("=")[0])
70
+//                .antMatchers(parametes.getAppSercurityPath().get(2).split("=")[1]).hasRole(parametes.getAppSercurityPath().get(2).split("=")[0])
71
+                .antMatchers("/app-api/tickets/**").hasRole("OWNER")
72
+               .and()
73
+                .sessionManagement()
74
+                .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
75
+               .and()
76
+                .httpBasic().authenticationEntryPoint(new RestAuthenticationEntryPoint())
77
+               .and()
78
+                .addFilter(getPreAuthenticatedProcessingFilter());
79
+
80
+
81
+    }
82
+
83
+    /**
84
+     * web安全链
85
+     * @param web
86
+     * @throws Exception
87
+     */
88
+    @Override
89
+    public void configure(WebSecurity web) throws Exception {
90
+        // 忽略
91
+        web.ignoring().antMatchers(HttpMethod.OPTIONS,"/**");
92
+
93
+    }
94
+}

+ 22
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/service/IRoleService.java 查看文件

@@ -0,0 +1,22 @@
1
+package com.community.huiju.service;
2
+
3
+import com.community.huiju.dto.RoleDTO;
4
+
5
+import java.util.List;
6
+
7
+public interface IRoleService {
8
+
9
+    /**
10
+     * 根据用户ID获取web端用户角色
11
+     * @param userId
12
+     * @return
13
+     */
14
+    List<RoleDTO> getWebUserRoleByUserId(Integer userId);
15
+
16
+    /**
17
+     * 根据用户ID获取app端用户角色
18
+     * @param userId
19
+     * @return
20
+     */
21
+    List<RoleDTO> getAppUserRoleByUserId(Integer userId);
22
+}

+ 10
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/service/IUserService.java 查看文件

@@ -0,0 +1,10 @@
1
+package com.community.huiju.service;
2
+
3
+/**
4
+ * @author weiximei
5
+ */
6
+public interface IUserService {
7
+
8
+
9
+
10
+}

+ 59
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/service/impl/RoleService.java 查看文件

@@ -0,0 +1,59 @@
1
+package com.community.huiju.service.impl;
2
+
3
+import com.community.huiju.dao.*;
4
+import com.community.huiju.dto.RoleDTO;
5
+import com.community.huiju.model.TaSysRole;
6
+import com.community.huiju.model.ToSysRole;
7
+import com.community.huiju.service.IRoleService;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.stereotype.Service;
10
+
11
+import java.util.ArrayList;
12
+import java.util.List;
13
+import java.util.stream.Collectors;
14
+
15
+/**
16
+ * 角色业务
17
+ * @author weiximei
18
+ */
19
+@Service("iRoleService")
20
+public class RoleService implements IRoleService {
21
+
22
+    @Autowired
23
+    private ToSysMenuMapper toSysMenuMapper;
24
+
25
+    @Autowired
26
+    private ToSysRoleMapper toSysRoleMapper;
27
+
28
+    @Autowired
29
+    private ToSysRoleMenuMapper toSysRoleMenuMapper;
30
+
31
+    @Autowired
32
+    private ToSysUserRoleMapper toSysUserRoleMapper;
33
+
34
+    @Autowired
35
+    private ToUserMapper toUserMapper;
36
+
37
+    @Autowired
38
+    private TaSysRoleMapper taSysRoleMapper;
39
+
40
+    @Override
41
+    public List<RoleDTO> getWebUserRoleByUserId(Integer userId) {
42
+        List<RoleDTO> roleDTOList = new ArrayList<>();
43
+        List<ToSysRole> roles = toSysRoleMapper.selectRoleByUserId(userId);
44
+        roleDTOList = roles.stream()
45
+                .map(e-> new RoleDTO(e.getId(),e.getRoleName()))
46
+                .collect(Collectors.toList());
47
+        return roleDTOList;
48
+    }
49
+
50
+    @Override
51
+    public List<RoleDTO> getAppUserRoleByUserId(Integer userId) {
52
+        List<RoleDTO> roleDTOList = new ArrayList<>();
53
+        List<TaSysRole> roles = taSysRoleMapper.selectRoleByUserId(userId);
54
+        roleDTOList = roles.stream()
55
+                .map(e-> new RoleDTO(e.getId(),e.getRoleName()))
56
+                .collect(Collectors.toList());
57
+        return roleDTOList;
58
+    }
59
+}

+ 16
- 0
CODE/smart-community/zuul/src/main/java/com/community/huiju/service/impl/UserService.java 查看文件

@@ -0,0 +1,16 @@
1
+package com.community.huiju.service.impl;
2
+
3
+import com.community.huiju.service.IUserService;
4
+import org.springframework.stereotype.Service;
5
+
6
+/**
7
+ * 用户业务
8
+ * @author weiximei
9
+ */
10
+@Service("iUserService")
11
+public class UserService implements IUserService {
12
+
13
+
14
+
15
+
16
+}

+ 3
- 1
CODE/smart-community/zuul/src/main/resources/application.yml 查看文件

@@ -2,4 +2,6 @@ management:
2 2
   endpoints:
3 3
     web:
4 4
       exposure:
5
-        include: refresh,health,info
5
+        include: refresh,health,info
6
+
7
+

+ 7
- 0
CODE/smart-community/zuul/src/main/resources/bootstrap.yml 查看文件

@@ -27,3 +27,10 @@ eureka:
27 27
 zuul:
28 28
   host:
29 29
     connect-timeout-millis: 200000
30
+
31
+## Mybatis
32
+mybatis:
33
+  typeAliasesPackage: com.community.huiju.model
34
+  mapperLocations: classpath:mapper/*.xml
35
+  configuration:
36
+    call-setters-on-nulls: true

+ 13
- 1
CODE/smart-community/zuul/src/main/resources/log4j.properties 查看文件

@@ -5,7 +5,7 @@ log4j.appender.A1.layout=org.apache.log4j.PatternLayout
5 5
 log4j.appender.A1.layout.ConversionPattern=%-5p%x [%t] %d - %c %m%n  
6 6
 
7 7
 log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
8
-log4j.appender.R.File=../logs/resold_admin_.log
8
+log4j.appender.R.File=../logs/zuul/resold_admin_.log
9 9
 log4j.appender.R.layout=org.apache.log4j.PatternLayout
10 10
 log4j.appender.R.Append = true
11 11
 log4j.appender.R.ImmediateFlush = true
@@ -17,3 +17,15 @@ log4j.logger.org.springframework.transaction.support.TransactionSynchronizationM
17 17
 log4j.logger.java.sql.Connection=DEBUG
18 18
 log4j.logger.java.sql.Statement=DEBUG
19 19
 log4j.logger.java.sql.PreparedStatement=DEBUG
20
+
21
+###############Log4j 4 SQL Output start################# #DEBUG
22
+log4j.logger.com.**.dao=INFO
23
+log4j.logger.com.springframework=DEBUG
24
+log4j.logger.com.ibatis=DEBUG  
25
+log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG  
26
+log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG  
27
+log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
28
+log4j.logger.java.sql.ResultSet=DEBUG
29
+log4j.logger.org.apache.ibatis.logging.commons.JakartaCommonsLoggingImpl=DEBUG
30
+log4j.logger.java.sql=DEBUG,CONSOLE 
31
+###############Log4j 4 SQL Output end###################

+ 130
- 0
CODE/smart-community/zuul/src/main/resources/mapper/TaSysRoleMapper.xml 查看文件

@@ -0,0 +1,130 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.community.huiju.dao.TaSysRoleMapper" >
4
+  <resultMap id="BaseResultMap" type="com.community.huiju.model.TaSysRole" >
5
+    <id column="id" property="id" jdbcType="INTEGER" />
6
+    <result column="role_name" property="roleName" jdbcType="VARCHAR" />
7
+    <result column="description" property="description" jdbcType="VARCHAR" />
8
+    <result column="create_user" property="createUser" jdbcType="INTEGER" />
9
+    <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
10
+    <result column="update_user" property="updateUser" jdbcType="INTEGER" />
11
+    <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
12
+  </resultMap>
13
+  <sql id="Base_Column_List" >
14
+    id, role_name, description, create_user, create_date, update_user, update_date
15
+  </sql>
16
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
17
+    select 
18
+    <include refid="Base_Column_List" />
19
+    from ta_sys_role
20
+    where id = #{id,jdbcType=INTEGER}
21
+  </select>
22
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
23
+    delete from ta_sys_role
24
+    where id = #{id,jdbcType=INTEGER}
25
+  </delete>
26
+  <insert id="insert" parameterType="com.community.huiju.model.TaSysRole" >
27
+    insert into ta_sys_role (id, role_name, description, 
28
+      create_user, create_date, update_user, 
29
+      update_date)
30
+    values (#{id,jdbcType=INTEGER}, #{roleName,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, 
31
+      #{createUser,jdbcType=INTEGER}, #{createDate,jdbcType=TIMESTAMP}, #{updateUser,jdbcType=INTEGER}, 
32
+      #{updateDate,jdbcType=TIMESTAMP})
33
+  </insert>
34
+  <insert id="insertSelective" parameterType="com.community.huiju.model.TaSysRole" >
35
+    insert into ta_sys_role
36
+    <trim prefix="(" suffix=")" suffixOverrides="," >
37
+      <if test="id != null" >
38
+        id,
39
+      </if>
40
+      <if test="roleName != null" >
41
+        role_name,
42
+      </if>
43
+      <if test="description != null" >
44
+        description,
45
+      </if>
46
+      <if test="createUser != null" >
47
+        create_user,
48
+      </if>
49
+      <if test="createDate != null" >
50
+        create_date,
51
+      </if>
52
+      <if test="updateUser != null" >
53
+        update_user,
54
+      </if>
55
+      <if test="updateDate != null" >
56
+        update_date,
57
+      </if>
58
+    </trim>
59
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
60
+      <if test="id != null" >
61
+        #{id,jdbcType=INTEGER},
62
+      </if>
63
+      <if test="roleName != null" >
64
+        #{roleName,jdbcType=VARCHAR},
65
+      </if>
66
+      <if test="description != null" >
67
+        #{description,jdbcType=VARCHAR},
68
+      </if>
69
+      <if test="createUser != null" >
70
+        #{createUser,jdbcType=INTEGER},
71
+      </if>
72
+      <if test="createDate != null" >
73
+        #{createDate,jdbcType=TIMESTAMP},
74
+      </if>
75
+      <if test="updateUser != null" >
76
+        #{updateUser,jdbcType=INTEGER},
77
+      </if>
78
+      <if test="updateDate != null" >
79
+        #{updateDate,jdbcType=TIMESTAMP},
80
+      </if>
81
+    </trim>
82
+  </insert>
83
+  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TaSysRole" >
84
+    update ta_sys_role
85
+    <set >
86
+      <if test="roleName != null" >
87
+        role_name = #{roleName,jdbcType=VARCHAR},
88
+      </if>
89
+      <if test="description != null" >
90
+        description = #{description,jdbcType=VARCHAR},
91
+      </if>
92
+      <if test="createUser != null" >
93
+        create_user = #{createUser,jdbcType=INTEGER},
94
+      </if>
95
+      <if test="createDate != null" >
96
+        create_date = #{createDate,jdbcType=TIMESTAMP},
97
+      </if>
98
+      <if test="updateUser != null" >
99
+        update_user = #{updateUser,jdbcType=INTEGER},
100
+      </if>
101
+      <if test="updateDate != null" >
102
+        update_date = #{updateDate,jdbcType=TIMESTAMP},
103
+      </if>
104
+    </set>
105
+    where id = #{id,jdbcType=INTEGER}
106
+  </update>
107
+  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.TaSysRole" >
108
+    update ta_sys_role
109
+    set role_name = #{roleName,jdbcType=VARCHAR},
110
+      description = #{description,jdbcType=VARCHAR},
111
+      create_user = #{createUser,jdbcType=INTEGER},
112
+      create_date = #{createDate,jdbcType=TIMESTAMP},
113
+      update_user = #{updateUser,jdbcType=INTEGER},
114
+      update_date = #{updateDate,jdbcType=TIMESTAMP}
115
+    where id = #{id,jdbcType=INTEGER}
116
+  </update>
117
+  <select id="findRoleByUserId" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
118
+    select
119
+    <include refid="Base_Column_List" />
120
+    from ta_sys_role
121
+    	where id = (select role_id from ta_sys_user_role where user_id = #{userId})
122
+  </select>
123
+
124
+  <select id="selectRoleByUserId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
125
+    select
126
+    tsr.*
127
+    from ta_sys_user_role tsur left join ta_sys_role tsr on tsur.role_id = tsr.id where tsur.user_id=#{userId}
128
+  </select>
129
+
130
+</mapper>

+ 89
- 0
CODE/smart-community/zuul/src/main/resources/mapper/TaSysUserRoleMapper.xml 查看文件

@@ -0,0 +1,89 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.community.huiju.dao.TaSysUserRoleMapper" >
4
+  <resultMap id="BaseResultMap" type="com.community.huiju.model.TaSysUserRole" >
5
+    <id column="id" property="id" jdbcType="INTEGER" />
6
+    <result column="community_id" property="communityId" jdbcType="INTEGER" />
7
+    <result column="user_id" property="userId" jdbcType="INTEGER" />
8
+    <result column="role_id" property="roleId" jdbcType="INTEGER" />
9
+  </resultMap>
10
+  <sql id="Base_Column_List" >
11
+    id, community_id, user_id, role_id
12
+  </sql>
13
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
14
+    select 
15
+    <include refid="Base_Column_List" />
16
+    from ta_sys_user_role
17
+    where id = #{id,jdbcType=INTEGER}
18
+  </select>
19
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
20
+    delete from ta_sys_user_role
21
+    where id = #{id,jdbcType=INTEGER}
22
+  </delete>
23
+  <insert id="insert" parameterType="com.community.huiju.model.TaSysUserRole" >
24
+    insert into ta_sys_user_role (id, community_id, user_id, 
25
+      role_id)
26
+    values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, 
27
+      #{roleId,jdbcType=INTEGER})
28
+  </insert>
29
+  <insert id="insertSelective" parameterType="com.community.huiju.model.TaSysUserRole" >
30
+    insert into ta_sys_user_role
31
+    <trim prefix="(" suffix=")" suffixOverrides="," >
32
+      <if test="id != null" >
33
+        id,
34
+      </if>
35
+      <if test="communityId != null" >
36
+        community_id,
37
+      </if>
38
+      <if test="userId != null" >
39
+        user_id,
40
+      </if>
41
+      <if test="roleId != null" >
42
+        role_id,
43
+      </if>
44
+    </trim>
45
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
46
+      <if test="id != null" >
47
+        #{id,jdbcType=INTEGER},
48
+      </if>
49
+      <if test="communityId != null" >
50
+        #{communityId,jdbcType=INTEGER},
51
+      </if>
52
+      <if test="userId != null" >
53
+        #{userId,jdbcType=INTEGER},
54
+      </if>
55
+      <if test="roleId != null" >
56
+        #{roleId,jdbcType=INTEGER},
57
+      </if>
58
+    </trim>
59
+  </insert>
60
+  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TaSysUserRole" >
61
+    update ta_sys_user_role
62
+    <set >
63
+      <if test="communityId != null" >
64
+        community_id = #{communityId,jdbcType=INTEGER},
65
+      </if>
66
+      <if test="userId != null" >
67
+        user_id = #{userId,jdbcType=INTEGER},
68
+      </if>
69
+      <if test="roleId != null" >
70
+        role_id = #{roleId,jdbcType=INTEGER},
71
+      </if>
72
+    </set>
73
+    where id = #{id,jdbcType=INTEGER}
74
+  </update>
75
+  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.TaSysUserRole" >
76
+    update ta_sys_user_role
77
+    set community_id = #{communityId,jdbcType=INTEGER},
78
+      user_id = #{userId,jdbcType=INTEGER},
79
+      role_id = #{roleId,jdbcType=INTEGER}
80
+    where id = #{id,jdbcType=INTEGER}
81
+  </update>
82
+
83
+  <select id="findSysUserRoleByUserIdAndRoleId" resultType="java.lang.Integer" parameterType="java.lang.Integer" >
84
+    select
85
+    count(*)
86
+    from ta_sys_user_role
87
+    where user_id = #{userId,jdbcType=INTEGER} and role_id = 1
88
+  </select>
89
+</mapper>

+ 276
- 0
CODE/smart-community/zuul/src/main/resources/mapper/TaUserMapper.xml 查看文件

@@ -0,0 +1,276 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.community.huiju.dao.TaUserMapper" >
4
+  <resultMap id="BaseResultMap" type="com.community.huiju.model.TaUser" >
5
+    <id column="id" property="id" jdbcType="INTEGER" />
6
+    <result column="community_id" property="communityId" jdbcType="INTEGER" />
7
+    <result column="building_owner_info_id" property="buildingOwnerInfoId" jdbcType="INTEGER" />
8
+    <result column="head_portrait" property="headPortrait" jdbcType="VARCHAR" />
9
+    <result column="user_name" property="userName" jdbcType="VARCHAR" />
10
+    <result column="login_name" property="loginName" jdbcType="VARCHAR" />
11
+    <result column="login_password" property="loginPassword" jdbcType="VARCHAR" />
12
+    <result column="email" property="email" jdbcType="VARCHAR" />
13
+    <result column="gender" property="gender" jdbcType="CHAR" />
14
+    <result column="status" property="status" jdbcType="CHAR" />
15
+    <result column="remark" property="remark" jdbcType="VARCHAR" />
16
+    <result column="parent_id" property="parentId" jdbcType="INTEGER" />
17
+    <result column="accept_agreement_status" property="acceptAgreementStatus" jdbcType="CHAR" />
18
+    <result column="verify_status" property="verifyStatus" jdbcType="CHAR" />
19
+    <result column="create_user" property="createUser" jdbcType="INTEGER" />
20
+    <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
21
+    <result column="update_user" property="updateUser" jdbcType="INTEGER" />
22
+    <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
23
+  </resultMap>
24
+  <sql id="Base_Column_List" >
25
+    id, community_id, building_owner_info_id, head_portrait, user_name, login_name, login_password, 
26
+    email, gender, status, remark, parent_id, accept_agreement_status, verify_status,
27
+    create_user, create_date, update_user, update_date
28
+  </sql>
29
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
30
+    select
31
+    <include refid="Base_Column_List" />
32
+    from ta_user
33
+    where id = #{id,jdbcType=INTEGER}
34
+  </select>
35
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
36
+    delete from ta_user
37
+    where id = #{id,jdbcType=INTEGER}
38
+  </delete>
39
+  <insert id="insert" parameterType="com.community.huiju.model.TaUser" >
40
+    insert into ta_user (id, community_id, building_owner_info_id,
41
+      head_portrait, user_name, login_name,
42
+      login_password, email, gender,
43
+      status, remark, parent_id,
44
+      accept_agreement_status, verify_status, create_user,
45
+      create_date, update_user, update_date
46
+      )
47
+    values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER}, #{buildingOwnerInfoId,jdbcType=INTEGER},
48
+      #{headPortrait,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR}, #{loginName,jdbcType=VARCHAR},
49
+      #{loginPassword,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{gender,jdbcType=CHAR},
50
+      #{status,jdbcType=CHAR}, #{remark,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER},
51
+      #{acceptAgreementStatus,jdbcType=CHAR}, #{verifyStatus,jdbcType=CHAR}, #{createUser,jdbcType=INTEGER},
52
+      #{createDate,jdbcType=TIMESTAMP}, #{updateUser,jdbcType=INTEGER}, #{updateDate,jdbcType=TIMESTAMP}
53
+      )
54
+  </insert>
55
+  <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="com.community.huiju.model.TaUser" >
56
+    insert into ta_user
57
+    <trim prefix="(" suffix=")" suffixOverrides="," >
58
+      <if test="id != null" >
59
+        id,
60
+      </if>
61
+      <if test="communityId != null" >
62
+        community_id,
63
+      </if>
64
+      <if test="buildingOwnerInfoId != null" >
65
+        building_owner_info_id,
66
+      </if>
67
+      <if test="headPortrait != null" >
68
+        head_portrait,
69
+      </if>
70
+      <if test="userName != null" >
71
+        user_name,
72
+      </if>
73
+      <if test="loginName != null" >
74
+        login_name,
75
+      </if>
76
+      <if test="loginPassword != null" >
77
+        login_password,
78
+      </if>
79
+      <if test="email != null" >
80
+        email,
81
+      </if>
82
+      <if test="gender != null" >
83
+        gender,
84
+      </if>
85
+      <if test="status != null" >
86
+        status,
87
+      </if>
88
+      <if test="remark != null" >
89
+        remark,
90
+      </if>
91
+      <if test="parentId != null" >
92
+        parent_id,
93
+      </if>
94
+      <if test="acceptAgreementStatus != null" >
95
+        accept_agreement_status,
96
+      </if>
97
+      <if test="verifyStatus != null" >
98
+        verify_status,
99
+      </if>
100
+      <if test="createUser != null" >
101
+        create_user,
102
+      </if>
103
+      <if test="createDate != null" >
104
+        create_date,
105
+      </if>
106
+      <if test="updateUser != null" >
107
+        update_user,
108
+      </if>
109
+      <if test="updateDate != null" >
110
+        update_date,
111
+      </if>
112
+    </trim>
113
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
114
+      <if test="id != null" >
115
+        #{id,jdbcType=INTEGER},
116
+      </if>
117
+      <if test="communityId != null" >
118
+        #{communityId,jdbcType=INTEGER},
119
+      </if>
120
+      <if test="buildingOwnerInfoId != null" >
121
+        #{buildingOwnerInfoId,jdbcType=INTEGER},
122
+      </if>
123
+      <if test="headPortrait != null" >
124
+        #{headPortrait,jdbcType=VARCHAR},
125
+      </if>
126
+      <if test="userName != null" >
127
+        #{userName,jdbcType=VARCHAR},
128
+      </if>
129
+      <if test="loginName != null" >
130
+        #{loginName,jdbcType=VARCHAR},
131
+      </if>
132
+      <if test="loginPassword != null" >
133
+        #{loginPassword,jdbcType=VARCHAR},
134
+      </if>
135
+      <if test="email != null" >
136
+        #{email,jdbcType=VARCHAR},
137
+      </if>
138
+      <if test="gender != null" >
139
+        #{gender,jdbcType=CHAR},
140
+      </if>
141
+      <if test="status != null" >
142
+        #{status,jdbcType=CHAR},
143
+      </if>
144
+      <if test="remark != null" >
145
+        #{remark,jdbcType=VARCHAR},
146
+      </if>
147
+      <if test="parentId != null" >
148
+        #{parentId,jdbcType=INTEGER},
149
+      </if>
150
+      <if test="acceptAgreementStatus != null" >
151
+        #{acceptAgreementStatus,jdbcType=CHAR},
152
+      </if>
153
+      <if test="verifyStatus != null" >
154
+        #{verifyStatus,jdbcType=CHAR},
155
+      </if>
156
+      <if test="createUser != null" >
157
+        #{createUser,jdbcType=INTEGER},
158
+      </if>
159
+      <if test="createDate != null" >
160
+        #{createDate,jdbcType=TIMESTAMP},
161
+      </if>
162
+      <if test="updateUser != null" >
163
+        #{updateUser,jdbcType=INTEGER},
164
+      </if>
165
+      <if test="updateDate != null" >
166
+        #{updateDate,jdbcType=TIMESTAMP},
167
+      </if>
168
+    </trim>
169
+  </insert>
170
+  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TaUser" >
171
+    update ta_user
172
+    <set >
173
+      <if test="communityId != null" >
174
+        community_id = #{communityId,jdbcType=INTEGER},
175
+      </if>
176
+      <if test="buildingOwnerInfoId != null" >
177
+        building_owner_info_id = #{buildingOwnerInfoId,jdbcType=INTEGER},
178
+      </if>
179
+      <if test="headPortrait != null" >
180
+        head_portrait = #{headPortrait,jdbcType=VARCHAR},
181
+      </if>
182
+      <if test="userName != null" >
183
+        user_name = #{userName,jdbcType=VARCHAR},
184
+      </if>
185
+      <if test="loginName != null" >
186
+        login_name = #{loginName,jdbcType=VARCHAR},
187
+      </if>
188
+      <if test="loginPassword != null" >
189
+        login_password = #{loginPassword,jdbcType=VARCHAR},
190
+      </if>
191
+      <if test="email != null" >
192
+        email = #{email,jdbcType=VARCHAR},
193
+      </if>
194
+      <if test="gender != null" >
195
+        gender = #{gender,jdbcType=CHAR},
196
+      </if>
197
+      <if test="status != null" >
198
+        status = #{status,jdbcType=CHAR},
199
+      </if>
200
+      <if test="remark != null" >
201
+        remark = #{remark,jdbcType=VARCHAR},
202
+      </if>
203
+      <if test="parentId != null" >
204
+        parent_id = #{parentId,jdbcType=INTEGER},
205
+      </if>
206
+      <if test="acceptAgreementStatus != null" >
207
+        accept_agreement_status = #{acceptAgreementStatus,jdbcType=CHAR},
208
+      </if>
209
+      <if test="verifyStatus != null" >
210
+        verify_status = #{verifyStatus,jdbcType=CHAR},
211
+      </if>
212
+      <if test="createUser != null" >
213
+        create_user = #{createUser,jdbcType=INTEGER},
214
+      </if>
215
+      <if test="createDate != null" >
216
+        create_date = #{createDate,jdbcType=TIMESTAMP},
217
+      </if>
218
+      <if test="updateUser != null" >
219
+        update_user = #{updateUser,jdbcType=INTEGER},
220
+      </if>
221
+      <if test="updateDate != null" >
222
+        update_date = #{updateDate,jdbcType=TIMESTAMP},
223
+      </if>
224
+    </set>
225
+    where id = #{id,jdbcType=INTEGER}
226
+  </update>
227
+  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.TaUser" >
228
+    update ta_user
229
+    set community_id = #{communityId,jdbcType=INTEGER},
230
+      building_owner_info_id = #{buildingOwnerInfoId,jdbcType=INTEGER},
231
+      head_portrait = #{headPortrait,jdbcType=VARCHAR},
232
+      user_name = #{userName,jdbcType=VARCHAR},
233
+      login_name = #{loginName,jdbcType=VARCHAR},
234
+      login_password = #{loginPassword,jdbcType=VARCHAR},
235
+      email = #{email,jdbcType=VARCHAR},
236
+      gender = #{gender,jdbcType=CHAR},
237
+      status = #{status,jdbcType=CHAR},
238
+      remark = #{remark,jdbcType=VARCHAR},
239
+      parent_id = #{parentId,jdbcType=INTEGER},
240
+      accept_agreement_status = #{acceptAgreementStatus,jdbcType=CHAR},
241
+      verify_status = #{verifyStatus,jdbcType=CHAR},
242
+      create_user = #{createUser,jdbcType=INTEGER},
243
+      create_date = #{createDate,jdbcType=TIMESTAMP},
244
+      update_user = #{updateUser,jdbcType=INTEGER},
245
+      update_date = #{updateDate,jdbcType=TIMESTAMP}
246
+    where id = #{id,jdbcType=INTEGER}
247
+  </update>
248
+
249
+  <select id="selectByLoginNameAndByLoginPassword" parameterType="map" resultMap="BaseResultMap" >
250
+    select
251
+    <include refid="Base_Column_List" />
252
+    from ta_user
253
+    where login_name=#{loginName,jdbcType=VARCHAR} and login_password = #{loginPassword,jdbcType=VARCHAR}
254
+  </select>
255
+
256
+  <select id="selectByLoginName" parameterType="map" resultMap="BaseResultMap" >
257
+    select
258
+    <include refid="Base_Column_List" />
259
+    from ta_user
260
+    where login_name=#{loginName,jdbcType=VARCHAR}
261
+  </select>
262
+
263
+  <select id="ubdateLongName" parameterType="com.community.huiju.model.TaUser" resultMap="BaseResultMap">
264
+    update ta_user
265
+    set
266
+    login_name = #{loginName,jdbcType=VARCHAR}
267
+    where id = #{id,jdbcType=INTEGER}
268
+  </select>
269
+
270
+  <select id="selectUserListByParentId" parameterType="java.lang.Integer" resultMap="BaseResultMap" >
271
+    select
272
+    <include refid="Base_Column_List" />
273
+    from ta_user
274
+    where parent_id = #{parentId}
275
+  </select>
276
+</mapper>

+ 128
- 0
CODE/smart-community/zuul/src/main/resources/mapper/ToSysMenuMapper.xml 查看文件

@@ -0,0 +1,128 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.community.huiju.dao.ToSysMenuMapper">
4
+  <resultMap id="BaseResultMap" type="com.community.huiju.model.ToSysMenu">
5
+    <id column="id" jdbcType="INTEGER" property="id" />
6
+    <result column="menu_name" jdbcType="VARCHAR" property="menuName" />
7
+    <result column="menu_url" jdbcType="VARCHAR" property="menuUrl" />
8
+    <result column="menu_icon" jdbcType="VARCHAR" property="menuIcon" />
9
+    <result column="parent_id" jdbcType="INTEGER" property="parentId" />
10
+    <result column="sort" jdbcType="INTEGER" property="sort" />
11
+    <result column="menu_type" jdbcType="CHAR" property="menuType" />
12
+    <result column="status" jdbcType="CHAR" property="status" />
13
+  </resultMap>
14
+  <sql id="Base_Column_List">
15
+    id, menu_name, menu_url, menu_icon, parent_id, sort, menu_type, status
16
+  </sql>
17
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
18
+    select 
19
+    <include refid="Base_Column_List" />
20
+    from to_sys_menu
21
+    where id = #{id,jdbcType=INTEGER}
22
+  </select>
23
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
24
+    delete from to_sys_menu
25
+    where id = #{id,jdbcType=INTEGER}
26
+  </delete>
27
+  <insert id="insert" parameterType="com.community.huiju.model.ToSysMenu">
28
+    insert into to_sys_menu (id, menu_name, menu_url, 
29
+      menu_icon, parent_id, sort, 
30
+      menu_type, status)
31
+    values (#{id,jdbcType=INTEGER}, #{menuName,jdbcType=VARCHAR}, #{menuUrl,jdbcType=VARCHAR}, 
32
+      #{menuIcon,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER}, #{sort,jdbcType=INTEGER}, 
33
+      #{menuType,jdbcType=CHAR}, #{status,jdbcType=CHAR})
34
+  </insert>
35
+  <insert id="insertSelective" parameterType="com.community.huiju.model.ToSysMenu">
36
+    insert into to_sys_menu
37
+    <trim prefix="(" suffix=")" suffixOverrides=",">
38
+      <if test="id != null">
39
+        id,
40
+      </if>
41
+      <if test="menuName != null">
42
+        menu_name,
43
+      </if>
44
+      <if test="menuUrl != null">
45
+        menu_url,
46
+      </if>
47
+      <if test="menuIcon != null">
48
+        menu_icon,
49
+      </if>
50
+      <if test="parentId != null">
51
+        parent_id,
52
+      </if>
53
+      <if test="sort != null">
54
+        sort,
55
+      </if>
56
+      <if test="menuType != null">
57
+        menu_type,
58
+      </if>
59
+      <if test="status != null">
60
+        status,
61
+      </if>
62
+    </trim>
63
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
64
+      <if test="id != null">
65
+        #{id,jdbcType=INTEGER},
66
+      </if>
67
+      <if test="menuName != null">
68
+        #{menuName,jdbcType=VARCHAR},
69
+      </if>
70
+      <if test="menuUrl != null">
71
+        #{menuUrl,jdbcType=VARCHAR},
72
+      </if>
73
+      <if test="menuIcon != null">
74
+        #{menuIcon,jdbcType=VARCHAR},
75
+      </if>
76
+      <if test="parentId != null">
77
+        #{parentId,jdbcType=INTEGER},
78
+      </if>
79
+      <if test="sort != null">
80
+        #{sort,jdbcType=INTEGER},
81
+      </if>
82
+      <if test="menuType != null">
83
+        #{menuType,jdbcType=CHAR},
84
+      </if>
85
+      <if test="status != null">
86
+        #{status,jdbcType=CHAR},
87
+      </if>
88
+    </trim>
89
+  </insert>
90
+  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.ToSysMenu">
91
+    update to_sys_menu
92
+    <set>
93
+      <if test="menuName != null">
94
+        menu_name = #{menuName,jdbcType=VARCHAR},
95
+      </if>
96
+      <if test="menuUrl != null">
97
+        menu_url = #{menuUrl,jdbcType=VARCHAR},
98
+      </if>
99
+      <if test="menuIcon != null">
100
+        menu_icon = #{menuIcon,jdbcType=VARCHAR},
101
+      </if>
102
+      <if test="parentId != null">
103
+        parent_id = #{parentId,jdbcType=INTEGER},
104
+      </if>
105
+      <if test="sort != null">
106
+        sort = #{sort,jdbcType=INTEGER},
107
+      </if>
108
+      <if test="menuType != null">
109
+        menu_type = #{menuType,jdbcType=CHAR},
110
+      </if>
111
+      <if test="status != null">
112
+        status = #{status,jdbcType=CHAR},
113
+      </if>
114
+    </set>
115
+    where id = #{id,jdbcType=INTEGER}
116
+  </update>
117
+  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.ToSysMenu">
118
+    update to_sys_menu
119
+    set menu_name = #{menuName,jdbcType=VARCHAR},
120
+      menu_url = #{menuUrl,jdbcType=VARCHAR},
121
+      menu_icon = #{menuIcon,jdbcType=VARCHAR},
122
+      parent_id = #{parentId,jdbcType=INTEGER},
123
+      sort = #{sort,jdbcType=INTEGER},
124
+      menu_type = #{menuType,jdbcType=CHAR},
125
+      status = #{status,jdbcType=CHAR}
126
+    where id = #{id,jdbcType=INTEGER}
127
+  </update>
128
+</mapper>

+ 135
- 0
CODE/smart-community/zuul/src/main/resources/mapper/ToSysRoleMapper.xml 查看文件

@@ -0,0 +1,135 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.community.huiju.dao.ToSysRoleMapper">
4
+  <resultMap id="BaseResultMap" type="com.community.huiju.model.ToSysRole">
5
+    <id column="id" jdbcType="INTEGER" property="id" />
6
+    <result column="role_name" jdbcType="VARCHAR" property="roleName" />
7
+    <result column="description" jdbcType="VARCHAR" property="description" />
8
+    <result column="status" jdbcType="CHAR" property="status" />
9
+    <result column="create_user" jdbcType="INTEGER" property="createUser" />
10
+    <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
11
+    <result column="update_user" jdbcType="INTEGER" property="updateUser" />
12
+    <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
13
+  </resultMap>
14
+  <sql id="Base_Column_List">
15
+    id, role_name, description, status, create_user, create_date, update_user, update_date
16
+  </sql>
17
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
18
+    select 
19
+    <include refid="Base_Column_List" />
20
+    from to_sys_role
21
+    where id = #{id,jdbcType=INTEGER}
22
+  </select>
23
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
24
+    delete from to_sys_role
25
+    where id = #{id,jdbcType=INTEGER}
26
+  </delete>
27
+  <insert id="insert" parameterType="com.community.huiju.model.ToSysRole">
28
+    insert into to_sys_role (id, role_name, description, 
29
+      status, create_user, create_date, 
30
+      update_user, update_date)
31
+    values (#{id,jdbcType=INTEGER}, #{roleName,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, 
32
+      #{status,jdbcType=CHAR}, #{createUser,jdbcType=INTEGER}, #{createDate,jdbcType=TIMESTAMP}, 
33
+      #{updateUser,jdbcType=INTEGER}, #{updateDate,jdbcType=TIMESTAMP})
34
+  </insert>
35
+  <insert id="insertSelective" parameterType="com.community.huiju.model.ToSysRole">
36
+    insert into to_sys_role
37
+    <trim prefix="(" suffix=")" suffixOverrides=",">
38
+      <if test="id != null">
39
+        id,
40
+      </if>
41
+      <if test="roleName != null">
42
+        role_name,
43
+      </if>
44
+      <if test="description != null">
45
+        description,
46
+      </if>
47
+      <if test="status != null">
48
+        status,
49
+      </if>
50
+      <if test="createUser != null">
51
+        create_user,
52
+      </if>
53
+      <if test="createDate != null">
54
+        create_date,
55
+      </if>
56
+      <if test="updateUser != null">
57
+        update_user,
58
+      </if>
59
+      <if test="updateDate != null">
60
+        update_date,
61
+      </if>
62
+    </trim>
63
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
64
+      <if test="id != null">
65
+        #{id,jdbcType=INTEGER},
66
+      </if>
67
+      <if test="roleName != null">
68
+        #{roleName,jdbcType=VARCHAR},
69
+      </if>
70
+      <if test="description != null">
71
+        #{description,jdbcType=VARCHAR},
72
+      </if>
73
+      <if test="status != null">
74
+        #{status,jdbcType=CHAR},
75
+      </if>
76
+      <if test="createUser != null">
77
+        #{createUser,jdbcType=INTEGER},
78
+      </if>
79
+      <if test="createDate != null">
80
+        #{createDate,jdbcType=TIMESTAMP},
81
+      </if>
82
+      <if test="updateUser != null">
83
+        #{updateUser,jdbcType=INTEGER},
84
+      </if>
85
+      <if test="updateDate != null">
86
+        #{updateDate,jdbcType=TIMESTAMP},
87
+      </if>
88
+    </trim>
89
+  </insert>
90
+  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.ToSysRole">
91
+    update to_sys_role
92
+    <set>
93
+      <if test="roleName != null">
94
+        role_name = #{roleName,jdbcType=VARCHAR},
95
+      </if>
96
+      <if test="description != null">
97
+        description = #{description,jdbcType=VARCHAR},
98
+      </if>
99
+      <if test="status != null">
100
+        status = #{status,jdbcType=CHAR},
101
+      </if>
102
+      <if test="createUser != null">
103
+        create_user = #{createUser,jdbcType=INTEGER},
104
+      </if>
105
+      <if test="createDate != null">
106
+        create_date = #{createDate,jdbcType=TIMESTAMP},
107
+      </if>
108
+      <if test="updateUser != null">
109
+        update_user = #{updateUser,jdbcType=INTEGER},
110
+      </if>
111
+      <if test="updateDate != null">
112
+        update_date = #{updateDate,jdbcType=TIMESTAMP},
113
+      </if>
114
+    </set>
115
+    where id = #{id,jdbcType=INTEGER}
116
+  </update>
117
+  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.ToSysRole">
118
+    update to_sys_role
119
+    set role_name = #{roleName,jdbcType=VARCHAR},
120
+      description = #{description,jdbcType=VARCHAR},
121
+      status = #{status,jdbcType=CHAR},
122
+      create_user = #{createUser,jdbcType=INTEGER},
123
+      create_date = #{createDate,jdbcType=TIMESTAMP},
124
+      update_user = #{updateUser,jdbcType=INTEGER},
125
+      update_date = #{updateDate,jdbcType=TIMESTAMP}
126
+    where id = #{id,jdbcType=INTEGER}
127
+  </update>
128
+
129
+  <select id="selectRoleByUserId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
130
+    select
131
+    role.*
132
+     from to_sys_user_role ur left join ta_sys_role role on ur.role_id = role.id where ur.user_id=#{userId}
133
+  </select>
134
+
135
+</mapper>

+ 71
- 0
CODE/smart-community/zuul/src/main/resources/mapper/ToSysRoleMenuMapper.xml 查看文件

@@ -0,0 +1,71 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.community.huiju.dao.ToSysRoleMenuMapper">
4
+  <resultMap id="BaseResultMap" type="com.community.huiju.model.ToSysRoleMenu">
5
+    <id column="id" jdbcType="INTEGER" property="id" />
6
+    <result column="role_id" jdbcType="INTEGER" property="roleId" />
7
+    <result column="menu_id" jdbcType="INTEGER" property="menuId" />
8
+  </resultMap>
9
+  <sql id="Base_Column_List">
10
+    id, role_id, menu_id
11
+  </sql>
12
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
13
+    select 
14
+    <include refid="Base_Column_List" />
15
+    from to_sys_role_menu
16
+    where id = #{id,jdbcType=INTEGER}
17
+  </select>
18
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
19
+    delete from to_sys_role_menu
20
+    where id = #{id,jdbcType=INTEGER}
21
+  </delete>
22
+  <insert id="insert" parameterType="com.community.huiju.model.ToSysRoleMenu">
23
+    insert into to_sys_role_menu (id, role_id, menu_id
24
+      )
25
+    values (#{id,jdbcType=INTEGER}, #{roleId,jdbcType=INTEGER}, #{menuId,jdbcType=INTEGER}
26
+      )
27
+  </insert>
28
+  <insert id="insertSelective" parameterType="com.community.huiju.model.ToSysRoleMenu">
29
+    insert into to_sys_role_menu
30
+    <trim prefix="(" suffix=")" suffixOverrides=",">
31
+      <if test="id != null">
32
+        id,
33
+      </if>
34
+      <if test="roleId != null">
35
+        role_id,
36
+      </if>
37
+      <if test="menuId != null">
38
+        menu_id,
39
+      </if>
40
+    </trim>
41
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
42
+      <if test="id != null">
43
+        #{id,jdbcType=INTEGER},
44
+      </if>
45
+      <if test="roleId != null">
46
+        #{roleId,jdbcType=INTEGER},
47
+      </if>
48
+      <if test="menuId != null">
49
+        #{menuId,jdbcType=INTEGER},
50
+      </if>
51
+    </trim>
52
+  </insert>
53
+  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.ToSysRoleMenu">
54
+    update to_sys_role_menu
55
+    <set>
56
+      <if test="roleId != null">
57
+        role_id = #{roleId,jdbcType=INTEGER},
58
+      </if>
59
+      <if test="menuId != null">
60
+        menu_id = #{menuId,jdbcType=INTEGER},
61
+      </if>
62
+    </set>
63
+    where id = #{id,jdbcType=INTEGER}
64
+  </update>
65
+  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.ToSysRoleMenu">
66
+    update to_sys_role_menu
67
+    set role_id = #{roleId,jdbcType=INTEGER},
68
+      menu_id = #{menuId,jdbcType=INTEGER}
69
+    where id = #{id,jdbcType=INTEGER}
70
+  </update>
71
+</mapper>

+ 71
- 0
CODE/smart-community/zuul/src/main/resources/mapper/ToSysUserRoleMapper.xml 查看文件

@@ -0,0 +1,71 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.community.huiju.dao.ToSysUserRoleMapper">
4
+  <resultMap id="BaseResultMap" type="com.community.huiju.model.ToSysUserRole">
5
+    <id column="id" jdbcType="INTEGER" property="id" />
6
+    <result column="user_id" jdbcType="INTEGER" property="userId" />
7
+    <result column="role_id" jdbcType="INTEGER" property="roleId" />
8
+  </resultMap>
9
+  <sql id="Base_Column_List">
10
+    id, user_id, role_id
11
+  </sql>
12
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
13
+    select 
14
+    <include refid="Base_Column_List" />
15
+    from to_sys_user_role
16
+    where id = #{id,jdbcType=INTEGER}
17
+  </select>
18
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
19
+    delete from to_sys_user_role
20
+    where id = #{id,jdbcType=INTEGER}
21
+  </delete>
22
+  <insert id="insert" parameterType="com.community.huiju.model.ToSysUserRole">
23
+    insert into to_sys_user_role (id, user_id, role_id
24
+      )
25
+    values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{roleId,jdbcType=INTEGER}
26
+      )
27
+  </insert>
28
+  <insert id="insertSelective" parameterType="com.community.huiju.model.ToSysUserRole">
29
+    insert into to_sys_user_role
30
+    <trim prefix="(" suffix=")" suffixOverrides=",">
31
+      <if test="id != null">
32
+        id,
33
+      </if>
34
+      <if test="userId != null">
35
+        user_id,
36
+      </if>
37
+      <if test="roleId != null">
38
+        role_id,
39
+      </if>
40
+    </trim>
41
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
42
+      <if test="id != null">
43
+        #{id,jdbcType=INTEGER},
44
+      </if>
45
+      <if test="userId != null">
46
+        #{userId,jdbcType=INTEGER},
47
+      </if>
48
+      <if test="roleId != null">
49
+        #{roleId,jdbcType=INTEGER},
50
+      </if>
51
+    </trim>
52
+  </insert>
53
+  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.ToSysUserRole">
54
+    update to_sys_user_role
55
+    <set>
56
+      <if test="userId != null">
57
+        user_id = #{userId,jdbcType=INTEGER},
58
+      </if>
59
+      <if test="roleId != null">
60
+        role_id = #{roleId,jdbcType=INTEGER},
61
+      </if>
62
+    </set>
63
+    where id = #{id,jdbcType=INTEGER}
64
+  </update>
65
+  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.ToSysUserRole">
66
+    update to_sys_user_role
67
+    set user_id = #{userId,jdbcType=INTEGER},
68
+      role_id = #{roleId,jdbcType=INTEGER}
69
+    where id = #{id,jdbcType=INTEGER}
70
+  </update>
71
+</mapper>

+ 177
- 0
CODE/smart-community/zuul/src/main/resources/mapper/ToUserMapper.xml 查看文件

@@ -0,0 +1,177 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.community.huiju.dao.ToUserMapper">
4
+  <resultMap id="BaseResultMap" type="com.community.huiju.model.ToUser">
5
+    <id column="id" jdbcType="INTEGER" property="id" />
6
+    <result column="user_name" jdbcType="VARCHAR" property="userName" />
7
+    <result column="login_name" jdbcType="VARCHAR" property="loginName" />
8
+    <result column="login_password" jdbcType="VARCHAR" property="loginPassword" />
9
+    <result column="email" jdbcType="VARCHAR" property="email" />
10
+    <result column="head_portrait" jdbcType="VARCHAR" property="headPortrait" />
11
+    <result column="remark" jdbcType="VARCHAR" property="remark" />
12
+    <result column="status" jdbcType="CHAR" property="status" />
13
+    <result column="create_user" jdbcType="INTEGER" property="createUser" />
14
+    <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
15
+    <result column="update_user" jdbcType="INTEGER" property="updateUser" />
16
+    <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
17
+  </resultMap>
18
+  <sql id="Base_Column_List">
19
+    id, user_name, login_name, login_password, email, head_portrait, remark, status, 
20
+    create_user, create_date, update_user, update_date
21
+  </sql>
22
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
23
+    select 
24
+    <include refid="Base_Column_List" />
25
+    from to_user
26
+    where id = #{id,jdbcType=INTEGER}
27
+  </select>
28
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
29
+    delete from to_user
30
+    where id = #{id,jdbcType=INTEGER}
31
+  </delete>
32
+  <insert id="insert" parameterType="com.community.huiju.model.ToUser">
33
+    insert into to_user (id, user_name, login_name, 
34
+      login_password, email, head_portrait, 
35
+      remark, status, create_user, 
36
+      create_date, update_user, update_date
37
+      )
38
+    values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR}, #{loginName,jdbcType=VARCHAR}, 
39
+      #{loginPassword,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{headPortrait,jdbcType=VARCHAR}, 
40
+      #{remark,jdbcType=VARCHAR}, #{status,jdbcType=CHAR}, #{createUser,jdbcType=INTEGER}, 
41
+      #{createDate,jdbcType=TIMESTAMP}, #{updateUser,jdbcType=INTEGER}, #{updateDate,jdbcType=TIMESTAMP}
42
+      )
43
+  </insert>
44
+  <insert id="insertSelective" parameterType="com.community.huiju.model.ToUser">
45
+    insert into to_user
46
+    <trim prefix="(" suffix=")" suffixOverrides=",">
47
+      <if test="id != null">
48
+        id,
49
+      </if>
50
+      <if test="userName != null">
51
+        user_name,
52
+      </if>
53
+      <if test="loginName != null">
54
+        login_name,
55
+      </if>
56
+      <if test="loginPassword != null">
57
+        login_password,
58
+      </if>
59
+      <if test="email != null">
60
+        email,
61
+      </if>
62
+      <if test="headPortrait != null">
63
+        head_portrait,
64
+      </if>
65
+      <if test="remark != null">
66
+        remark,
67
+      </if>
68
+      <if test="status != null">
69
+        status,
70
+      </if>
71
+      <if test="createUser != null">
72
+        create_user,
73
+      </if>
74
+      <if test="createDate != null">
75
+        create_date,
76
+      </if>
77
+      <if test="updateUser != null">
78
+        update_user,
79
+      </if>
80
+      <if test="updateDate != null">
81
+        update_date,
82
+      </if>
83
+    </trim>
84
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
85
+      <if test="id != null">
86
+        #{id,jdbcType=INTEGER},
87
+      </if>
88
+      <if test="userName != null">
89
+        #{userName,jdbcType=VARCHAR},
90
+      </if>
91
+      <if test="loginName != null">
92
+        #{loginName,jdbcType=VARCHAR},
93
+      </if>
94
+      <if test="loginPassword != null">
95
+        #{loginPassword,jdbcType=VARCHAR},
96
+      </if>
97
+      <if test="email != null">
98
+        #{email,jdbcType=VARCHAR},
99
+      </if>
100
+      <if test="headPortrait != null">
101
+        #{headPortrait,jdbcType=VARCHAR},
102
+      </if>
103
+      <if test="remark != null">
104
+        #{remark,jdbcType=VARCHAR},
105
+      </if>
106
+      <if test="status != null">
107
+        #{status,jdbcType=CHAR},
108
+      </if>
109
+      <if test="createUser != null">
110
+        #{createUser,jdbcType=INTEGER},
111
+      </if>
112
+      <if test="createDate != null">
113
+        #{createDate,jdbcType=TIMESTAMP},
114
+      </if>
115
+      <if test="updateUser != null">
116
+        #{updateUser,jdbcType=INTEGER},
117
+      </if>
118
+      <if test="updateDate != null">
119
+        #{updateDate,jdbcType=TIMESTAMP},
120
+      </if>
121
+    </trim>
122
+  </insert>
123
+  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.ToUser">
124
+    update to_user
125
+    <set>
126
+      <if test="userName != null">
127
+        user_name = #{userName,jdbcType=VARCHAR},
128
+      </if>
129
+      <if test="loginName != null">
130
+        login_name = #{loginName,jdbcType=VARCHAR},
131
+      </if>
132
+      <if test="loginPassword != null">
133
+        login_password = #{loginPassword,jdbcType=VARCHAR},
134
+      </if>
135
+      <if test="email != null">
136
+        email = #{email,jdbcType=VARCHAR},
137
+      </if>
138
+      <if test="headPortrait != null">
139
+        head_portrait = #{headPortrait,jdbcType=VARCHAR},
140
+      </if>
141
+      <if test="remark != null">
142
+        remark = #{remark,jdbcType=VARCHAR},
143
+      </if>
144
+      <if test="status != null">
145
+        status = #{status,jdbcType=CHAR},
146
+      </if>
147
+      <if test="createUser != null">
148
+        create_user = #{createUser,jdbcType=INTEGER},
149
+      </if>
150
+      <if test="createDate != null">
151
+        create_date = #{createDate,jdbcType=TIMESTAMP},
152
+      </if>
153
+      <if test="updateUser != null">
154
+        update_user = #{updateUser,jdbcType=INTEGER},
155
+      </if>
156
+      <if test="updateDate != null">
157
+        update_date = #{updateDate,jdbcType=TIMESTAMP},
158
+      </if>
159
+    </set>
160
+    where id = #{id,jdbcType=INTEGER}
161
+  </update>
162
+  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.ToUser">
163
+    update to_user
164
+    set user_name = #{userName,jdbcType=VARCHAR},
165
+      login_name = #{loginName,jdbcType=VARCHAR},
166
+      login_password = #{loginPassword,jdbcType=VARCHAR},
167
+      email = #{email,jdbcType=VARCHAR},
168
+      head_portrait = #{headPortrait,jdbcType=VARCHAR},
169
+      remark = #{remark,jdbcType=VARCHAR},
170
+      status = #{status,jdbcType=CHAR},
171
+      create_user = #{createUser,jdbcType=INTEGER},
172
+      create_date = #{createDate,jdbcType=TIMESTAMP},
173
+      update_user = #{updateUser,jdbcType=INTEGER},
174
+      update_date = #{updateDate,jdbcType=TIMESTAMP}
175
+    where id = #{id,jdbcType=INTEGER}
176
+  </update>
177
+</mapper>

+ 2
- 0
CODE/smart-community/zuul/src/main/resources/parametes.properties 查看文件

@@ -0,0 +1,2 @@
1
+security.noneSercurityPath=/**/user/login/**,/**/user/register/**,/**/code/sendCode/**,/**/authentication/require/**
2
+security.appSercurityPath=OWNER=/**/tickets/**,TENANT=/**/app-api/**,RELATION=/**/app-api/**