Ver código fonte

提交代码

mengshibin 4 anos atrás
commit
e59b307000
84 arquivos alterados com 5821 adições e 0 exclusões
  1. 68 0
      4dkankan-user-application/pom.xml
  2. 26 0
      4dkankan-user-application/src/main/java/com/fdkankan/Application.java
  3. 37 0
      4dkankan-user-application/src/main/resources/application-dev.properties
  4. 37 0
      4dkankan-user-application/src/main/resources/application-pro.properties
  5. 37 0
      4dkankan-user-application/src/main/resources/application-test.properties
  6. 21 0
      4dkankan-user-application/src/main/resources/application.properties
  7. 156 0
      4dkankan-user-application/src/main/resources/logback-spring.xml
  8. 16 0
      4dkankan-user-application/src/test/java/com/fdkankan/XiaoanApplicationTests.java
  9. 213 0
      4dkankan-user-common/pom.xml
  10. 10 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/aop/SystemControllerLog.java
  11. 10 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/aop/SystemServiceLog.java
  12. 31 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/config/MyNacosLifecycle.java
  13. 89 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/config/Swagger2.java
  14. 36 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/config/WebMvcConfig.java
  15. 92 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/constant/MsgCode.java
  16. 35 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/exception/BaseRuntimeException.java
  17. 46 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/exception/GlobalExceptionHandler.java
  18. 45 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/interceptor/CommonInterceptor.java
  19. 77 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/model/BaseModel.java
  20. 24 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/model/PageDto.java
  21. 83 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/util/Base64Converter.java
  22. 199 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/util/PasswordUtils.java
  23. 121 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/util/RandomValidateCodeUtil.java
  24. 30 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/util/RegexUtils.java
  25. 101 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/util/Result.java
  26. 148 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/util/ResultJson.java
  27. 218 0
      4dkankan-user-common/src/main/java/com/fdkankan/common/util/SnowFlakeUUidUtils.java
  28. 26 0
      4dkankan-user-dao/pom.xml
  29. 23 0
      4dkankan-user-dao/src/main/java/com/fdkankan/dao/backend/DepartmentRepository.java
  30. 19 0
      4dkankan-user-dao/src/main/java/com/fdkankan/dao/backend/IBaseRepository.java
  31. 11 0
      4dkankan-user-dao/src/main/java/com/fdkankan/dao/backend/ResourceRepository.java
  32. 29 0
      4dkankan-user-dao/src/main/java/com/fdkankan/dao/backend/RoleRepository.java
  33. 40 0
      4dkankan-user-dao/src/main/java/com/fdkankan/dao/backend/UserRepository.java
  34. 11 0
      4dkankan-user-dao/src/main/java/com/fdkankan/dao/backend/UserRoleRepository.java
  35. 32 0
      4dkankan-user-dao/src/main/java/com/fdkankan/dao/backend/provider/UserProvider.java
  36. 27 0
      4dkankan-user-domain/pom.xml
  37. 32 0
      4dkankan-user-domain/src/main/java/com/fdkankan/domain/backend/DepartmentEntity.java
  38. 46 0
      4dkankan-user-domain/src/main/java/com/fdkankan/domain/backend/ResourceEntity.java
  39. 26 0
      4dkankan-user-domain/src/main/java/com/fdkankan/domain/backend/RoleEntity.java
  40. 37 0
      4dkankan-user-domain/src/main/java/com/fdkankan/domain/backend/UserEntity.java
  41. 24 0
      4dkankan-user-domain/src/main/java/com/fdkankan/domain/backend/UserRoleEntity.java
  42. 22 0
      4dkankan-user-domain/src/main/java/com/fdkankan/domain/dto/request/DepartmentRequest.java
  43. 32 0
      4dkankan-user-domain/src/main/java/com/fdkankan/domain/dto/request/OperationRequest.java
  44. 29 0
      4dkankan-user-domain/src/main/java/com/fdkankan/domain/dto/request/ResourceRequest.java
  45. 28 0
      4dkankan-user-domain/src/main/java/com/fdkankan/domain/dto/request/RoleRequest.java
  46. 34 0
      4dkankan-user-domain/src/main/java/com/fdkankan/domain/dto/request/UserRequest.java
  47. 65 0
      4dkankan-user-domain/src/main/java/com/fdkankan/domain/dto/response/ResponseCamera.java
  48. 33 0
      4dkankan-user-domain/src/main/java/com/fdkankan/domain/dto/response/UserResponse.java
  49. 30 0
      4dkankan-user-service/pom.xml
  50. 157 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/BaseServiceImpl.java
  51. 49 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/IBaseService.java
  52. 16 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/backend/DepartmentService.java
  53. 24 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/backend/ResourceService.java
  54. 21 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/backend/RoleService.java
  55. 10 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/backend/UserRoleService.java
  56. 32 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/backend/UserService.java
  57. 78 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/backend/dto/DepartmentTree.java
  58. 138 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/backend/dto/ResourceTree.java
  59. 20 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/backend/feign/CameraFeign.java
  60. 19 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/backend/feign/OperatorFeign.java
  61. 38 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/backend/impl/DepartmentServiceImpl.java
  62. 133 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/backend/impl/ResourceServiceImpl.java
  63. 53 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/backend/impl/RoleServiceImpl.java
  64. 26 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/backend/impl/UserRoleServiceImpl.java
  65. 72 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/backend/impl/UserServiceImpl.java
  66. 107 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/backend/util/DepartmentTreeUtil.java
  67. 103 0
      4dkankan-user-service/src/main/java/com/fdkankan/service/backend/util/ResourceTreeUtil.java
  68. 26 0
      4dkankan-user-web/pom.xml
  69. 97 0
      4dkankan-user-web/src/main/java/com/fdkankan/web/aop/CheckCurrenUserAspect.java
  70. 10 0
      4dkankan-user-web/src/main/java/com/fdkankan/web/aop/CheckCurrentUser.java
  71. 13 0
      4dkankan-user-web/src/main/java/com/fdkankan/web/aop/WebControllerLog.java
  72. 149 0
      4dkankan-user-web/src/main/java/com/fdkankan/web/aop/WebLogAspect.java
  73. 20 0
      4dkankan-user-web/src/main/java/com/fdkankan/web/backend/BaseController.java
  74. 216 0
      4dkankan-user-web/src/main/java/com/fdkankan/web/backend/DepartmentController.java
  75. 281 0
      4dkankan-user-web/src/main/java/com/fdkankan/web/backend/IndexController.java
  76. 101 0
      4dkankan-user-web/src/main/java/com/fdkankan/web/backend/ResourceController.java
  77. 123 0
      4dkankan-user-web/src/main/java/com/fdkankan/web/backend/RoleController.java
  78. 285 0
      4dkankan-user-web/src/main/java/com/fdkankan/web/backend/UserController.java
  79. 130 0
      4dkankan-user-web/src/main/java/com/fdkankan/web/shiro/JWTFilter.java
  80. 23 0
      4dkankan-user-web/src/main/java/com/fdkankan/web/shiro/JWTToken.java
  81. 73 0
      4dkankan-user-web/src/main/java/com/fdkankan/web/shiro/JWTUtil.java
  82. 151 0
      4dkankan-user-web/src/main/java/com/fdkankan/web/shiro/MyRealm.java
  83. 172 0
      4dkankan-user-web/src/main/java/com/fdkankan/web/shiro/ShiroConfig.java
  84. 193 0
      pom.xml

+ 68 - 0
4dkankan-user-application/pom.xml

@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.fdkankan</groupId>
+    <artifactId>4dkankan-user-application</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>war</packaging>
+    <name>4dkankan-user-application</name>
+    <description>项目入口</description>
+
+    <parent>
+        <artifactId>fdkankan</artifactId>
+        <groupId>com.fdkankan</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <properties>
+        <java.version>1.8</java.version>
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-user-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-user-common</artifactId>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <finalName>4dkankan_user</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <!-- 指定该Main Class为全局的唯一入口 -->
+                    <mainClass>com.fdkankan.App</mainClass>
+                    <fork>true</fork>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>${java.version}</source>
+                    <target>${java.version}</target>
+                    <encoding>UTF-8</encoding>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 26 - 0
4dkankan-user-application/src/main/java/com/fdkankan/Application.java

@@ -0,0 +1,26 @@
+package com.fdkankan;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+
+import javax.annotation.PostConstruct;
+
+@EnableFeignClients
+@EnableDiscoveryClient
+@SpringBootApplication
+public class Application extends SpringBootServletInitializer {
+
+    @Override
+    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
+        return application.sources(Application.class);
+    }
+
+    public static void main(String[] args) {
+        SpringApplication.run(Application.class, args);
+    }
+
+}

+ 37 - 0
4dkankan-user-application/src/main/resources/application-dev.properties

@@ -0,0 +1,37 @@
+#应用名
+spring.application.name=4dkankan-user
+#注册中心
+spring.cloud.nacos.discovery.server-addr=192.168.0.98:8848
+
+spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
+spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
+spring.datasource.druid.url=jdbc:mysql://localhost:3306/4dkankan_hd?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+spring.datasource.druid.username=root
+spring.datasource.druid.password=123456
+
+
+spring.datasource.druid.initial-size=5
+spring.datasource.druid.min-idle=10
+spring.datasource.druid.max-active=20
+spring.datasource.druid.max-wait=60000
+spring.datasource.druid.time-between-eviction-runs-millis=60000
+spring.datasource.druid.min-evictable-idle-time-millis=30000
+spring.datasource.druid.max-evictable-idle-time-millis=90000
+spring.datasource.druid.validation-query=SELECT 1 FROM DUAL
+spring.datasource.druid.test-while-idle=true
+spring.datasource.druid.test-on-borrow=false
+spring.datasource.druid.test-on-return=false
+spring.datasource.druid.web-stat-filter.enabled=true
+spring.datasource.druid.stat-view-servlet.enabled=true
+
+#logging.file=log/xiaoan.log
+
+spring.redis.cluster.nodes=10.1.152.54:6379
+spring.redis.database=0
+spring.redis.password=
+spring.redis.timeout=3000ms
+spring.redis.jedis.pool.max-idle=8
+spring.redis.jedis.pool.min-idle=0
+spring.redis.jedis.pool.max-active=8
+spring.redis.jedis.pool.max-wait=-1ms

+ 37 - 0
4dkankan-user-application/src/main/resources/application-pro.properties

@@ -0,0 +1,37 @@
+#应用名
+spring.application.name=4dkankan-user
+#注册中心
+spring.cloud.nacos.discovery.server-addr=10.71.9.205:80
+
+spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
+spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
+spring.datasource.druid.url=jdbc:mysql://10.71.188.241:3306/db_4dkankan?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+spring.datasource.druid.username=user_4dkankan_rw
+spring.datasource.druid.password=AE1ksBti1goH8f4zVbPj
+
+
+spring.datasource.druid.initial-size=5
+spring.datasource.druid.min-idle=10
+spring.datasource.druid.max-active=20
+spring.datasource.druid.max-wait=60000
+spring.datasource.druid.time-between-eviction-runs-millis=60000
+spring.datasource.druid.min-evictable-idle-time-millis=30000
+spring.datasource.druid.max-evictable-idle-time-millis=90000
+spring.datasource.druid.validation-query=SELECT 1 FROM DUAL
+spring.datasource.druid.test-while-idle=true
+spring.datasource.druid.test-on-borrow=false
+spring.datasource.druid.test-on-return=false
+spring.datasource.druid.web-stat-filter.enabled=true
+spring.datasource.druid.stat-view-servlet.enabled=true
+
+#logging.file=log/xiaoan.log
+
+spring.redis.cluster.nodes=10.71.188.181:7000,10.71.188.108:7000,10.71.188.113:7000,10.71.188.206:7000,10.71.188.238:7000,10.71.188.148:7000
+spring.redis.database=0
+spring.redis.password=m8P6JugfYevMBi8bUnlu
+spring.redis.timeout=3000ms
+spring.redis.jedis.pool.max-idle=8
+spring.redis.jedis.pool.min-idle=0
+spring.redis.jedis.pool.max-active=8
+spring.redis.jedis.pool.max-wait=-1ms

+ 37 - 0
4dkankan-user-application/src/main/resources/application-test.properties

@@ -0,0 +1,37 @@
+#应用名
+spring.application.name=4dkankan-user
+#注册中心
+spring.cloud.nacos.discovery.server-addr=10.71.5.163:80
+
+spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
+spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
+spring.datasource.druid.url=jdbc:mysql://10.71.184.146:3306/db_4dkankan?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+spring.datasource.druid.username=user_4dkankan_rw
+spring.datasource.druid.password=y2b9a42wRwGNKkJjCm1o
+
+
+spring.datasource.druid.initial-size=5
+spring.datasource.druid.min-idle=10
+spring.datasource.druid.max-active=20
+spring.datasource.druid.max-wait=60000
+spring.datasource.druid.time-between-eviction-runs-millis=60000
+spring.datasource.druid.min-evictable-idle-time-millis=30000
+spring.datasource.druid.max-evictable-idle-time-millis=90000
+spring.datasource.druid.validation-query=SELECT 1 FROM DUAL
+spring.datasource.druid.test-while-idle=true
+spring.datasource.druid.test-on-borrow=false
+spring.datasource.druid.test-on-return=false
+spring.datasource.druid.web-stat-filter.enabled=true
+spring.datasource.druid.stat-view-servlet.enabled=true
+
+#logging.file=log/xiaoan.log
+
+spring.redis.cluster.nodes=10.71.184.237:7000,10.71.184.181:7000,10.71.184.217:7000,10.71.184.188:7000,10.71.184.222:7000,10.71.184.200:7000
+spring.redis.database=0
+spring.redis.password=QBzhHTxfcYLTs0n5J5VQ
+spring.redis.timeout=3000ms
+spring.redis.jedis.pool.max-idle=8
+spring.redis.jedis.pool.min-idle=0
+spring.redis.jedis.pool.max-active=8
+spring.redis.jedis.pool.max-wait=-1ms

+ 21 - 0
4dkankan-user-application/src/main/resources/application.properties

@@ -0,0 +1,21 @@
+server.port=8010
+
+spring.profiles.active=test
+
+#mybatis
+#mybatis.mapper-locations=classpath:mapper/*.xml
+#mybatis.type-aliases-package=com.xiaoan.dao.*
+mybatis.configuration.mapUnderscoreToCamelCase=true
+mapper.identity=MYSQL
+mapper.mappers=tk.mybatis.mapper.common.Mapper
+#pager
+pagehelper.helper-dialect=mysql
+pagehelper.params=count=countSql
+pagehelper.reasonable=false
+pagehelper.support-methods-arguments=true
+
+#log
+logging.path=G:/javaProject/4dkankan_hd_user/4dkankan-user/log
+logging.config=classpath:logback-spring.xml
+logging.level.com.fdkankan=debug
+

+ 156 - 0
4dkankan-user-application/src/main/resources/logback-spring.xml

@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration scan="true" scanPeriod="60 seconds" debug="false">
+    <property name="LOG_MAX_HISTORY" value="180"/>
+    <springProperty scope="context" name="LOG_PATH" source="logging.path"/>
+
+    <!-- 控制台输出 -->
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
+            <pattern>${LOG_PATH}/%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
+            <!--<charset>utf-8</charset>-->
+        </encoder>
+    </appender>
+    <!-- 按照每天生成日志文件:主项目日志 -->
+    <appender name="file.all" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!-- 追加日志到原文件结尾 -->
+        <Prudent>true</Prudent>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!--日志文件输出的文件名 -->
+            <FileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
+            <MaxHistory>${LOG_MAX_HISTORY}</MaxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <!-- 除按日志记录之外,还配置了日志文件不能超过10M(默认),若超过10M,日志文件会以索引0开始, -->
+                <maxFileSize>10MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{500} - %msg%n</pattern>
+            <!--<charset>utf-8</charset>-->
+        </encoder>
+    </appender>
+
+    <!--info日志统一输出到这里-->
+    <appender name="file.info" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <Prudent>true</Prudent>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!--日志文件输出的文件名 每小时生成日志文件 -->
+            <FileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}/info/console-info.%d{yyyy-MM-dd-HH}.%i.log</FileNamePattern>
+            <MaxHistory>${LOG_MAX_HISTORY}</MaxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <!-- 除按日志记录之外,还配置了日志文件不能超过10M(默认),若超过10M,日志文件会以索引0开始, -->
+                <maxFileSize>10MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %method 方法名  %L 行数 %msg:日志消息,%n是换行符-->
+            <pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{56}.%method:%L - %msg%n</pattern>
+            <!--<charset>utf-8</charset>-->
+        </encoder>
+        <!-- 此日志文件只记录info级别的 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>INFO</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <!--错误日志统一输出到这里-->
+    <appender name="file.error" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <Prudent>true</Prudent>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!--日志文件输出的文件名-->
+            <FileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}/error/console-error.%d{yyyy-MM-dd-HH}.%i.log</FileNamePattern>
+            <!--日志文件保留天数-->
+            <MaxHistory>${LOG_MAX_HISTORY}</MaxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <!-- 除按日志记录之外,还配置了日志文件不能超过10M(默认),若超过10M,日志文件会以索引0开始, -->
+                <maxFileSize>10MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %method 方法名  %L 行数 %msg:日志消息,%n是换行符-->
+            <pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{56}.%method:%L - %msg%n</pattern>
+            <!--<charset>utf-8</charset>-->
+        </encoder>
+        <!-- 此日志文件只记录error级别的 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>ERROR</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <!--warn日志统一输出到这里-->
+    <appender name="file.warn" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <Prudent>true</Prudent>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!--日志文件输出的文件名 按小时生成日志-->
+            <FileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}/warn/console-warn.%d{yyyy-MM-dd-HH}.%i.log</FileNamePattern>
+            <!--日志文件保留天数-->
+            <MaxHistory>${LOG_MAX_HISTORY}</MaxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <!-- 除按日志记录之外,还配置了日志文件不能超过10M(默认),若超过10M,日志文件会以索引0开始, -->
+                <maxFileSize>10MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %method 方法名  %L 行数 %msg:日志消息,%n是换行符-->
+            <pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{56}.%method:%L - %msg%n</pattern>
+            <!--<charset>utf-8</charset>-->
+        </encoder>
+        <!-- 此日志文件只记录warn级别的 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>WARN</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <!--debug级别日志统一输出到这里-->
+    <appender name="file.debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <Prudent>true</Prudent>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!--日志文件输出的文件名 按小时生成日志-->
+            <FileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}/debug/console-debug.%d{yyyy-MM-dd-HH}.%i.log</FileNamePattern>
+            <!--日志文件保留天数-->
+            <MaxHistory>${LOG_MAX_HISTORY}</MaxHistory>
+            <!-- 除按日志记录之外,还配置了日志文件不能超过5M,若超过5M,日志文件会以索引0开始,命名日志文件,例如console-debug.2018-08-24-09.1.log -->
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>10MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %method 方法名  %L 行数 %msg:日志消息,%n是换行符-->
+            <pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{56}.%method:%L - %msg%n</pattern>
+            <!--<charset>utf-8</charset>-->
+        </encoder>
+        <!-- 此日志文件只记录debug级别的 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>DEBUG</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY </onMismatch>
+        </filter>
+    </appender>
+
+    <!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
+    <appender name="file.async" class="ch.qos.logback.classic.AsyncAppender">
+        <discardingThreshold>0</discardingThreshold>
+        <queueSize>256</queueSize>
+        <includeCallerData>true</includeCallerData>
+        <appender-ref ref="file.all" />
+    </appender>
+
+    <!--  日志输出级别 -->
+    <!-- TRACE\DEBUG\INFO\WARN\ERROR\FATAL\OFF -->
+    <root level="INFO">
+        <appender-ref ref="console" />
+        <appender-ref ref="file.async"/>
+        <appender-ref ref="file.error" />
+        <appender-ref ref="file.info" />
+        <appender-ref ref="file.debug" />
+        <appender-ref ref="file.warn" />
+    </root>
+
+</configuration>

+ 16 - 0
4dkankan-user-application/src/test/java/com/fdkankan/XiaoanApplicationTests.java

@@ -0,0 +1,16 @@
+//package com.xiaoan;
+//
+//import org.junit.Test;
+//import org.junit.runner.RunWith;
+//import org.springframework.boot.test.context.SpringBootTest;
+//import org.springframework.test.context.junit4.SpringRunner;
+//
+//@RunWith(SpringRunner.class)
+//@SpringBootTest
+//public class XiaoanApplicationTests {
+//
+//    @Test
+//    public void contextLoads() {
+//    }
+//
+//}

+ 213 - 0
4dkankan-user-common/pom.xml

@@ -0,0 +1,213 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>fdkankan</artifactId>
+        <groupId>com.fdkankan</groupId>
+        <version>1.0-SNAPSHOT</version>
+        <!--<relativePath>../pom.xml</relativePath>-->
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>4dkankan-user-common</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0.0</version>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.springframework.cloud</groupId>
+                <artifactId>spring-cloud-dependencies</artifactId>
+                <version>Greenwich.SR2</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.springframework.cloud</groupId>
+                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
+                <version>0.9.0.RELEASE</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <!--spring boot -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot</artifactId>
+            <version>2.0.6.RELEASE</version>
+        </dependency>
+        <!-- spring boot -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+            <!--<exclusions>-->
+                <!--<exclusion>-->
+                    <!--<groupId>org.springframework.boot</groupId>-->
+                    <!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
+                <!--</exclusion>-->
+            <!--</exclusions>-->
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-tomcat</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-jdbc</artifactId>
+            <version>2.0.6.RELEASE</version>
+        </dependency>
+
+        <!-- JPA -->
+        <!--<dependency>-->
+            <!--<groupId>org.springframework.boot</groupId>-->
+            <!--<artifactId>spring-boot-starter-data-jpa</artifactId>-->
+        <!--</dependency>-->
+
+        <!-- nacos注册中心 -->
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+        </dependency>
+        <!-- nacos 依赖 -->
+        <dependency>
+            <groupId>com.alibaba.boot</groupId>
+            <artifactId>nacos-config-spring-boot-starter</artifactId>
+            <version>${nacos-config-spring-boot.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-openfeign</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!--springboot中的redis依赖-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
+
+        <!-- lombok -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+
+        <!-- fastjson -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+        </dependency>
+
+        <!-- mysql -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+
+        <!--阿里数据库连接池 -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid-spring-boot-starter</artifactId>
+            <!--<artifactId>druid</artifactId>-->
+        </dependency>
+
+        <!--swagger2核心包和swagger-ui界面包-->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+        </dependency>
+
+        <!-- 工具类 -->
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
+
+        <!-- shiro -->
+        <dependency>
+            <groupId>org.apache.shiro</groupId>
+            <artifactId>shiro-spring</artifactId>
+        </dependency>
+
+
+        <!-- jwt -->
+        <dependency>
+            <groupId>com.auth0</groupId>
+            <artifactId>java-jwt</artifactId>
+        </dependency>
+
+        <!--tk.mybatis 依赖-->
+        <dependency>
+            <groupId>tk.mybatis</groupId>
+            <artifactId>mapper-spring-boot-starter</artifactId>
+            <version>2.0.2</version>
+        </dependency>
+
+        <!--<dependency>-->
+            <!--<groupId>tk.mybatis</groupId>-->
+            <!--<artifactId>mapper</artifactId>-->
+            <!--<version>4.0.3</version>-->
+        <!--</dependency>-->
+
+        <!--分页插件-->
+        <dependency>
+            <groupId>com.github.pagehelper</groupId>
+            <artifactId>pagehelper-spring-boot-starter</artifactId>
+            <version>1.2.5</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.aspectj</groupId>
+            <artifactId>aspectjweaver</artifactId>
+            <version>1.9.3</version>
+        </dependency>
+
+        <!--<dependency>-->
+            <!--<groupId>com.fasterxml.jackson.core</groupId>-->
+            <!--<artifactId>jackson-annotations</artifactId>-->
+            <!--<version>2.9.5</version>-->
+        <!--</dependency>-->
+        <!--<dependency>-->
+            <!--<groupId>com.fasterxml.jackson.core</groupId>-->
+            <!--<artifactId>jackson-core</artifactId>-->
+            <!--<version>2.9.5</version>-->
+        <!--</dependency>-->
+
+        <!-- knife4j aip 包-->
+        <dependency>
+            <groupId>com.github.xiaoymin</groupId>
+            <artifactId>knife4j-spring-boot-starter</artifactId>
+            <version>2.0.2</version>
+        </dependency>
+
+        <!--<dependency>-->
+            <!--<groupId>org.4dage</groupId>-->
+            <!--<artifactId>4dage-back-sdk</artifactId>-->
+            <!--<version>1.0.2-RELEASE</version>-->
+        <!--</dependency>-->
+
+
+    </dependencies>
+
+
+</project>

+ 10 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/aop/SystemControllerLog.java

@@ -0,0 +1,10 @@
+package com.fdkankan.common.aop;
+
+import java.lang.annotation.*;
+
+@Target({ElementType.PARAMETER, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface SystemControllerLog {
+    String description() default "";
+}

+ 10 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/aop/SystemServiceLog.java

@@ -0,0 +1,10 @@
+package com.fdkankan.common.aop;
+
+import java.lang.annotation.*;
+
+@Target({ElementType.PARAMETER, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface SystemServiceLog {
+    String description() default "";
+}

+ 31 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/config/MyNacosLifecycle.java

@@ -0,0 +1,31 @@
+package com.fdkankan.common.config;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cloud.alibaba.nacos.registry.NacosAutoServiceRegistration;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.env.Environment;
+
+/**
+ * Created by Hb_zzZ on 2021/1/11.
+ */
+@Configuration
+public class MyNacosLifecycle implements ApplicationContextAware {
+
+    @Autowired(required = false)
+    private NacosAutoServiceRegistration registration;
+
+    @Autowired
+    private Environment environment;
+
+    @Override
+    public void setApplicationContext(ApplicationContext context) throws BeansException {
+        if (registration != null) {
+            String port = environment.getProperty("server.port");
+            registration.setPort(Integer.parseInt(port));
+            registration.start();
+        }
+    }
+}

+ 89 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/config/Swagger2.java

@@ -0,0 +1,89 @@
+package com.fdkankan.common.config;
+
+import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
+import com.google.common.collect.Lists;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.ApiKey;
+import springfox.documentation.service.AuthorizationScope;
+import springfox.documentation.service.SecurityReference;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spi.service.contexts.SecurityContext;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by owen on 2020/2/18
+ *
+ * 集成Swagger有3步:
+ * 1.pom.xml添加依赖
+ * 2.添加Swagger2.class
+ * 3.Application.class 加上注解@EnableSwagger2 表示开启Swagger
+ * 4.http://localhost:8080/doc.html#/
+ *
+ * 2.9.2 不需要字启动类配置注解
+ */
+//@EnableKnife4j 开启动态响应值
+@Configuration
+@EnableSwagger2
+@EnableKnife4j
+public class Swagger2 {
+    @Bean
+    public Docket createRestApi() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(apiInfo())
+                .select()
+                .apis(RequestHandlerSelectors.basePackage("com.fdkankan.web"))
+                .paths(PathSelectors.any())
+                .build()
+                //添加登录认证,可以使用token
+                .securityContexts(securityContexts())
+                .securitySchemes(securitySchemes())
+                ;
+    }
+
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+                .title("四维看看")
+                .description("四维看看Api接口文档")
+                .version("1.0")
+                .build();
+    }
+
+    private List<ApiKey> securitySchemes() {
+        //设置请求头信息
+        List<ApiKey> result = new ArrayList<>();
+//        ApiKey apiKey = new ApiKey("Authorization", "Authorization", "header");
+        ApiKey apiKey = new ApiKey("token", "token", "header");
+        result.add(apiKey);
+        return result;
+
+    }
+
+
+    private List<SecurityContext> securityContexts() {
+
+        SecurityContext context = SecurityContext.builder()
+                .securityReferences(defaultAuth())
+                .build();
+
+        return Lists.newArrayList(context);
+
+    }
+
+    private List<SecurityReference> defaultAuth() {
+        List<SecurityReference> result = new ArrayList<>();
+        AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
+        AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
+        authorizationScopes[0] = authorizationScope;
+        result.add(new SecurityReference("Authorization", authorizationScopes));
+        return result;
+    }
+}

+ 36 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/config/WebMvcConfig.java

@@ -0,0 +1,36 @@
+package com.fdkankan.common.config;
+
+import com.fdkankan.common.interceptor.CommonInterceptor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+/**
+ * Created by owen on 2020/2/18 0018 12:01
+ */
+@Configuration
+public class WebMvcConfig implements WebMvcConfigurer {
+
+    @Autowired
+    private CommonInterceptor commonInterceptor;
+    /**
+     * 配置全局跨域
+     */
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+        registry.addMapping("/**")
+                .allowedOrigins("*")
+                .allowCredentials(true)
+                .allowedMethods("GET", "POST", "DELETE", "PUT", "OPTIONS")
+                .maxAge(3600);
+    }
+
+    /**
+     * 添加拦截器
+     */
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        registry.addInterceptor(commonInterceptor).addPathPatterns("/**");
+    }
+}

+ 92 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/constant/MsgCode.java

@@ -0,0 +1,92 @@
+package com.fdkankan.common.constant;
+
+/**
+ * Created by Owen on 2019/10/25 0025 15:10
+ */
+public class MsgCode {
+
+    public static final int SUCCESS_CODE = 200;
+    public static final String SUCCESS_MSG = "success";
+
+    public static final int ERROR_CODE = 500;
+    public static final String ERROR_MSG = "error";
+
+    public static final int FAILURE_CODE_3001 = 3001;
+    public static final String FAILURE_MSG_3001 = "缺少必要参数";
+
+    public static final int FAILURE_CODE_3002 = 3002;
+    public static final String FAILURE_MSG_3002 = "token失效";
+
+    public static final int FAILURE_CODE_3004 = 3004;
+    public static final String FAILURE_MSG_3004 = "用户未登录";
+
+    //400x是用户模块的
+    public static final int FAILURE_CODE_4001 = 4001;
+    public static final String FAILURE_MSG_4001 = "账号或密码错误,请重新登录";
+
+    public static final int FAILURE_CODE_4002 = 4002;
+    public static final String FAILURE_MSG_4002 = "密码不正确";
+
+    public static final int FAILURE_CODE_4003 = 4003;
+    public static final String FAILURE_MSG_4003 = "该账户已停用,请跟管理员联系";
+
+    public static final int FAILURE_CODE_4004 = 4004;
+    public static final String FAILURE_MSG_4004 = "两次密码输入不一致";
+
+    public static final int FAILURE_CODE_4005 = 4005;
+    public static final String FAILURE_MSG_4005 = "手机号格式错误";
+
+    public static final int FAILURE_CODE_4006 = 4006;
+    public static final String FAILURE_MSG_4006 = "手机号已存在";
+
+    public static final int FAILURE_CODE_4007 = 4007;
+    public static final String FAILURE_MSG_4007 = "密码必须包含数字、字母,长度8-16个字符";
+
+    public static final int FAILURE_CODE_4008 = 4008;
+    public static final String FAILURE_MSG_4008 = "验证码错误";
+
+    public static final int FAILURE_CODE_4009 = 4009;
+    public static final String FAILURE_MSG_4009 = "连续登录失败5次,请5分钟后再次登录";
+
+    public static final int FAILURE_CODE_4010 = 4010;
+    public static final String FAILURE_MSG_4010 = "该用户无权操作";
+
+    public static final int FAILURE_CODE_4011 = 4011;
+    public static final String FAILURE_MSG_4011 = "用户不存在";
+
+    //500x是部门模块的
+    public static final int FAILURE_CODE_5001 = 5001;
+    public static final String FAILURE_MSG_5001 = "公司已存在";
+
+    public static final int FAILURE_CODE_5002 = 5002;
+    public static final String FAILURE_MSG_5002 = "公司不存在";
+
+    public static final int FAILURE_CODE_5003 = 5003;
+    public static final String FAILURE_MSG_5003 = "请先删除公司下用户并解绑相机";
+
+    public static final int FAILURE_CODE_5004 = 5004;
+    public static final String FAILURE_MSG_5004 = "上级公司不存在";
+
+    public static final int FAILURE_CODE_5005 = 5005;
+    public static final String FAILURE_MSG_5005 = "下级公司不能再增加下级公司";
+
+
+    //500x是部门模块的
+    public static final int FAILURE_CODE_6001 = 6001;
+    public static final String FAILURE_MSG_6001 = "角色不存在";
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}

+ 35 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/exception/BaseRuntimeException.java

@@ -0,0 +1,35 @@
+package com.fdkankan.common.exception;
+
+public class BaseRuntimeException extends RuntimeException{
+
+    private static final long serialVersionUID = -1518945670203783450L;
+    private Integer code;
+    private String msg;
+
+    public BaseRuntimeException(String msg){
+        super(msg);
+        this.msg = msg;
+    }
+
+    public BaseRuntimeException(Integer code, String msg){
+        super(msg);
+        this.code = code;
+        this.msg = msg;
+    }
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public void setCode(Integer code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+}

+ 46 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/exception/GlobalExceptionHandler.java

@@ -0,0 +1,46 @@
+package com.fdkankan.common.exception;
+
+import com.fdkankan.common.util.Result;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 全局异常捕获统一返回客户端
+ */
+@Log4j2
+@RestControllerAdvice
+public class GlobalExceptionHandler {
+
+//    @ResponseBody
+//    @ExceptionHandler(Exception.class)
+//    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
+    public Result exceptionHandler(HttpServletRequest request, Exception e) {
+        log.error(request.getRequestURI() + ":" + e.getCause());
+        Result result = Result.failure("系统错误:"+ e);
+//        if (e instanceof RuntimeException){
+//            String msg = e.getCause() == null ? e.toString() : e.getCause().getMessage();
+//            if (msg.contains("Load balancer does not have available server for client")){
+//                result = Result.failure(msg.split(":")[1] + "服务不可用");
+//            }
+//            if (e instanceof BaseFeignException){
+//                result = Result.failure( Result.CODE_FAILURE, e.getMessage());
+//            }
+//        }
+        return result;
+    }
+
+    @ResponseBody
+    @ExceptionHandler(BaseRuntimeException.class)
+    @ResponseStatus(HttpStatus.OK)
+    public Result runtimeExceptionHandler(HttpServletRequest request, BaseRuntimeException e) {
+        log.error(request.getRequestURI() + ":" + e.getMsg());
+        return Result.failure(e.getCode() == null ? Result.CODE_FAILURE : e.getCode(), e.getMsg());
+    }
+
+}

+ 45 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/interceptor/CommonInterceptor.java

@@ -0,0 +1,45 @@
+package com.fdkankan.common.interceptor;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@Slf4j
+@Component
+public class CommonInterceptor implements HandlerInterceptor {
+
+    @Override
+    public boolean preHandle(HttpServletRequest request,
+                             HttpServletResponse response, Object handler) throws Exception {
+        if(!request.getRequestURI().contains("/static/") && !request.getRequestURI().contains("/sendUserInfo")
+                && !request.getRequestURI().contains(".json") && !request.getRequestURI().contains(".png")
+                && !request.getRequestURI().contains(".html") && !request.getRequestURI().contains(".mp3")){
+            log.info(request.getRequestURI() + ",进入该请求!");
+        }
+        return true;
+    }
+
+    @Override
+    public void postHandle(HttpServletRequest request,
+                           HttpServletResponse response, Object handler,
+                           ModelAndView modelAndView) throws Exception {
+        request.setAttribute("ctx", request.getContextPath());
+    }
+
+    @Override
+    public void afterCompletion(HttpServletRequest request,
+                                HttpServletResponse response, Object handler, Exception ex)
+            throws Exception {
+        if(!request.getRequestURI().contains("/static/") && !request.getRequestURI().contains("/sendUserInfo")
+                && !request.getRequestURI().contains(".json") && !request.getRequestURI().contains(".png")
+                && !request.getRequestURI().contains(".html") && !request.getRequestURI().contains(".mp3")){
+            log.info(request.getRequestURI() + ",完成请求!");
+        }
+    }
+
+
+}

+ 77 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/model/BaseModel.java

@@ -0,0 +1,77 @@
+package com.fdkankan.common.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+import javax.persistence.*;
+import java.util.Date;
+
+@MappedSuperclass
+public abstract class BaseModel {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private String id;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+    /**
+     * 用来批量操作的
+     * 0: 激活  1:禁用
+     */
+    @JsonIgnore
+    @JSONField(serialize = false)
+    @Column(length = 1)
+    private String isDelete; // 0: 激活  1:禁用
+
+//    @Column
+//    private String createBy;
+
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getIsDelete() {
+        return isDelete;
+    }
+
+    public void setIsDelete(String isDelete) {
+        this.isDelete = isDelete;
+    }
+
+//    public String getCreateBy() {
+//        return createBy;
+//    }
+//
+//    public void setCreateBy(String createBy) {
+//        this.createBy = createBy;
+//    }
+}

+ 24 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/model/PageDto.java

@@ -0,0 +1,24 @@
+package com.fdkankan.common.model;
+
+import lombok.Data;
+
+import java.util.Date;
+
+
+/**
+ * Created by Owen on 2019/10/28 0028 12:24
+ */
+@Data
+public class PageDto {
+
+    private int pageNum;
+
+    private int pageSize;
+
+//    private Date startDate;
+//
+//    private Date endDate;
+
+
+
+}

+ 83 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/util/Base64Converter.java

@@ -0,0 +1,83 @@
+package com.fdkankan.common.util;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Base64;
+
+/**
+ * Created by Hb_zzZ on 2020/4/17.
+ */
+public class Base64Converter {
+
+    final static Base64.Encoder encoder = Base64.getEncoder();
+    final static Base64.Decoder decoder = Base64.getDecoder();
+
+    /**
+     * 给字符串加密
+     * @param text
+     * @return
+     */
+    public static String encode(String text) {
+        byte[] textByte = new byte[0];
+        try {
+            textByte = text.getBytes("UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        String encodedText = encoder.encodeToString(textByte);
+        return encodedText;
+    }
+
+    /**
+     * 将加密后的字符串进行解密
+     * @param encodedText
+     * @return
+     */
+    public static String decode(String encodedText) {
+        String text = null;
+        try {
+            text = new String(decoder.decode(encodedText), "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return text;
+    }
+
+    /**
+     * 根据逻辑截取加密后的密码
+     * @param text
+     * @return
+     */
+    public static String subText(String text){
+        //去掉前8位字符串
+        text = text.substring(8);
+        //去掉后8位字符串
+        text = text.substring(0, text.length() - 8);
+        //最后两个字符串换到前面,并且去掉剩下的后8位字符串
+        String result = text.substring(text.length() - 2) + text.substring(0, text.length() - 10);
+        return result;
+    }
+
+    public static void main(String[] args) throws UnsupportedEncodingException {
+
+//        String username = "Miracle Luna";
+        String password = "NjI5NjkwMTU4ODg4ODg2Mjk2OTAxNTg4NjI5NjkwMTU=";
+
+        password = password.substring(8);
+        System.out.println(password);
+        password = password.substring(0, password.length() - 8);
+        System.out.println(password);
+        String key = password.substring(password.length() - 2) + password.substring(0, password.length() - 10);
+        System.out.println(key);
+
+
+        // 加密
+//        System.out.println("====  [加密后] 用户名/密码  =====");
+//        System.out.println(Base64Converter.encode(username));
+//        System.out.println(Base64Converter.encode(password));
+
+        // 解密
+        System.out.println("\n====  [解密后] 用户名/密码  =====");
+//        System.out.println(Base64Converter.decode(Base64Converter.encode(username)));
+        System.out.println(Base64Converter.decode(key));
+    }
+}

+ 199 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/util/PasswordUtils.java

@@ -0,0 +1,199 @@
+package com.fdkankan.common.util;
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+import javax.crypto.spec.PBEParameterSpec;
+import java.security.Key;
+import java.security.SecureRandom;
+
+public class PasswordUtils {
+
+
+    /**
+     * JAVA6支持以下任意一种算法 PBEWITHMD5ANDDES PBEWITHMD5ANDTRIPLEDES
+     * PBEWITHSHAANDDESEDE PBEWITHSHA1ANDRC2_40 PBKDF2WITHHMACSHA1
+     * */
+
+    /**
+     * 定义使用的算法为:PBEWITHMD5andDES算法
+     */
+    public static final String ALGORITHM = "PBEWithMD5AndDES";//加密算法
+    public static final String Salt = "63293188";//密钥
+
+    /**
+     * 定义迭代次数为1000次
+     */
+    private static final int ITERATIONCOUNT = 1000;
+
+    /**
+     * 获取加密算法中使用的盐值,解密中使用的盐值必须与加密中使用的相同才能完成操作. 盐长度必须为8字节
+     *
+     * @return byte[] 盐值
+     */
+    public static byte[] getSalt() throws Exception {
+        // 实例化安全随机数
+        SecureRandom random = new SecureRandom();
+        // 产出盐
+        return random.generateSeed(8);
+    }
+
+    public static byte[] getStaticSalt() {
+        // 产出盐
+        return Salt.getBytes();
+    }
+
+    /**
+     * 根据PBE密码生成一把密钥
+     *
+     * @param password 生成密钥时所使用的密码
+     * @return Key PBE算法密钥
+     */
+    private static Key getPBEKey(String password) {
+        // 实例化使用的算法
+        SecretKeyFactory keyFactory;
+        SecretKey secretKey = null;
+        try {
+            keyFactory = SecretKeyFactory.getInstance(ALGORITHM);
+            // 设置PBE密钥参数
+            PBEKeySpec keySpec = new PBEKeySpec(password.toCharArray());
+            // 生成密钥
+            secretKey = keyFactory.generateSecret(keySpec);
+        } catch (Exception e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+        return secretKey;
+    }
+
+    /**
+     * 加密明文字符串
+     *
+     * @param plaintext 待加密的明文字符串
+     * @param password  生成密钥时所使用的密码
+     * @param salt      盐值
+     * @return 加密后的密文字符串
+     * @throws Exception
+     */
+    public static String encrypt(String plaintext, String password, byte[] salt) {
+
+        Key key = getPBEKey(password);
+        byte[] encipheredData = null;
+        PBEParameterSpec parameterSpec = new PBEParameterSpec(salt, ITERATIONCOUNT);
+        try {
+            Cipher cipher = Cipher.getInstance(ALGORITHM);
+
+            cipher.init(Cipher.ENCRYPT_MODE, key, parameterSpec);
+
+            encipheredData = cipher.doFinal(plaintext.getBytes());
+        } catch (Exception e) {
+        }
+        return bytesToHexString(encipheredData);
+    }
+
+    /**
+     * 解密密文字符串
+     *
+     * @param ciphertext 待解密的密文字符串
+     * @param password   生成密钥时所使用的密码(如需解密,该参数需要与加密时使用的一致)
+     * @param salt       盐值(如需解密,该参数需要与加密时使用的一致)
+     * @return 解密后的明文字符串
+     * @throws Exception
+     */
+    public static String decrypt(String ciphertext, String password, byte[] salt) throws Exception{
+
+        Key key = getPBEKey(password);
+        byte[] passDec = null;
+        PBEParameterSpec parameterSpec = new PBEParameterSpec(getStaticSalt(), ITERATIONCOUNT);
+        Cipher cipher = Cipher.getInstance(ALGORITHM);
+
+        cipher.init(Cipher.DECRYPT_MODE, key, parameterSpec);
+
+        passDec = cipher.doFinal(hexStringToBytes(ciphertext));
+        return new String(passDec);
+    }
+
+    /**
+     * 将字节数组转换为十六进制字符串
+     *
+     * @param src 字节数组
+     * @return
+     */
+    public static String bytesToHexString(byte[] src) {
+        StringBuilder stringBuilder = new StringBuilder("");
+        if (src == null || src.length <= 0) {
+            return null;
+        }
+        for (int i = 0; i < src.length; i++) {
+            int v = src[i] & 0xFF;
+            String hv = Integer.toHexString(v);
+            if (hv.length() < 2) {
+                stringBuilder.append(0);
+            }
+            stringBuilder.append(hv);
+        }
+        return stringBuilder.toString();
+    }
+
+    /**
+     * 将十六进制字符串转换为字节数组
+     *
+     * @param hexString 十六进制字符串
+     * @return
+     */
+    public static byte[] hexStringToBytes(String hexString) {
+        if (hexString == null || hexString.equals("")) {
+            return null;
+        }
+        hexString = hexString.toUpperCase();
+        int length = hexString.length() / 2;
+        char[] hexChars = hexString.toCharArray();
+        byte[] d = new byte[length];
+        for (int i = 0; i < length; i++) {
+            int pos = i * 2;
+            d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
+        }
+        return d;
+    }
+
+    private static byte charToByte(char c) {
+        return (byte) "0123456789ABCDEF".indexOf(c);
+    }
+
+    public static void main(String[] args) {
+
+        String userName = "88888888888";
+        String password = "123456";
+
+        try {
+            byte[] salt = PasswordUtils.getStaticSalt();
+            String ciphertext = PasswordUtils.encrypt(userName, password, salt);
+            System.out.println(ciphertext);
+            String plaintext = PasswordUtils.decrypt(ciphertext, password, salt);
+            System.out.println(plaintext);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+
+//        String userName = "admin";
+//        String password = "123456";
+//        try {
+//            byte[] salt = PasswordUtils.getStaticSalt();
+////            String ciphertext = PasswordUtils.encrypt(userName, password, salt);
+////            System.out.println(ciphertext);
+//            String plaintext = PasswordUtils.decrypt("2c01ba92b4dab363", password, salt);
+//            System.out.println(plaintext);
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+
+
+
+
+    }
+
+
+}

+ 121 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/util/RandomValidateCodeUtil.java

@@ -0,0 +1,121 @@
+package com.fdkankan.common.util;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+
+import javax.imageio.ImageIO;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+@Slf4j
+public class RandomValidateCodeUtil {
+
+    public static final String RANDOMCODEKEY = "RANDOMVALIDATECODEKEY";//放到session中的key
+    private String randString = "0123456789";//随机产生只有数字的字符串 private String
+    //private String randString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";//随机产生只有字母的字符串
+    //private String randString = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";//随机产生数字与字母组合的字符串
+    private int width = 95;// 图片宽
+    private int height = 25;// 图片高
+    private int lineSize = 40;// 干扰线数量
+    private int stringNum = 4;// 随机产生字符数量
+
+    private Random random = new Random();
+
+    /**
+     * 获得字体
+     */
+    private Font getFont() {
+        return new Font("Fixedsys", Font.CENTER_BASELINE, 18);
+    }
+
+    /**
+     * 获得颜色
+     */
+    private Color getRandColor(int fc, int bc) {
+        if (fc > 255)
+            fc = 255;
+        if (bc > 255)
+            bc = 255;
+        int r = fc + random.nextInt(bc - fc - 16);
+        int g = fc + random.nextInt(bc - fc - 14);
+        int b = fc + random.nextInt(bc - fc - 18);
+        return new Color(r, g, b);
+    }
+
+    /**
+     * 生成随机图片
+     */
+    public void getRandcode(HttpServletRequest request, HttpServletResponse response, RedisTemplate<String, String> redisTemplate) {
+        // BufferedImage类是具有缓冲区的Image类,Image类是用于描述图像信息的类
+        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
+        Graphics g = image.getGraphics();// 产生Image对象的Graphics对象,改对象可以在图像上进行各种绘制操作
+        g.fillRect(0, 0, width, height);//图片大小
+        g.setFont(new Font("Times New Roman", Font.ROMAN_BASELINE, 18));//字体大小
+        g.setColor(getRandColor(110, 133));//字体颜色
+        // 绘制干扰线
+        for (int i = 0; i <= lineSize; i++) {
+            drowLine(g);
+        }
+        // 绘制随机字符
+        String randomString = "";
+        for (int i = 1; i <= stringNum; i++) {
+            randomString = drowString(g, randomString, i);
+        }
+        log.info("验证码为:" + randomString);
+        //将生成的随机字符串保存到session中
+//        session.removeAttribute(RANDOMCODEKEY);
+//        session.setAttribute(RANDOMCODEKEY, randomString);
+        // 生产验证码字符串并保存到 Redis 中,ip-rightCode,有效期为 1 小时
+        String key = request.getParameter("key");
+        redisTemplate.opsForValue().set("validateCode#" + key, randomString, 10, TimeUnit.MINUTES);
+
+        g.dispose();
+        try {
+            // 将内存中的图片通过流动形式输出到客户端
+            ImageIO.write(image, "JPEG", response.getOutputStream());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    /**
+     * 绘制字符串
+     */
+    private String drowString(Graphics g, String randomString, int i) {
+        g.setFont(getFont());
+        g.setColor(new Color(random.nextInt(101), random.nextInt(111), random
+                .nextInt(121)));
+        String rand = String.valueOf(getRandomString(random.nextInt(randString
+                .length())));
+        randomString += rand;
+        g.translate(random.nextInt(3), random.nextInt(3));
+        g.drawString(rand, 13 * i, 16);
+        return randomString;
+    }
+
+    /**
+     * 绘制干扰线
+     */
+    private void drowLine(Graphics g) {
+        int x = random.nextInt(width);
+        int y = random.nextInt(height);
+        int xl = random.nextInt(13);
+        int yl = random.nextInt(15);
+        g.drawLine(x, y, x + xl, y + yl);
+    }
+
+    /**
+     * 获取随机的字符
+     */
+    public String getRandomString(int num) {
+        return String.valueOf(randString.charAt(num));
+    }
+}

+ 30 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/util/RegexUtils.java

@@ -0,0 +1,30 @@
+package com.fdkankan.common.util;
+
+import java.util.regex.Pattern;
+
+/**
+ * Created by Hb_zzZ on 2021/1/13.
+ */
+public class RegexUtils {
+
+    /**
+     *  正则:手机号(简单), 1字头+10位数字即可.
+     * @param in
+     * @return
+     */
+    public static boolean validateMobilePhone(String in) {
+        Pattern pattern = Pattern.compile("^[1]\\d{10}$");
+        return pattern.matcher(in).matches();
+    }
+
+    public static boolean validatePassword(String in) {
+        Pattern pattern = Pattern.compile("^(?=.*\\d)(?=.*[a-zA-Z])[\\da-zA-Z`]{8,16}$");
+        return pattern.matcher(in).matches();
+    }
+
+    public static void main(String[] args) {
+        System.out.println(validatePassword("17778014396"));
+
+        System.out.println(validatePassword("12a3A4567"));
+    }
+}

+ 101 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/util/Result.java

@@ -0,0 +1,101 @@
+package com.fdkankan.common.util;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 通用返回类
+ *
+ * @author
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class Result<T> implements Serializable {
+    private static final long serialVersionUID = -1491499610244557029L;
+    public static final String SUCCESS_MSG = "操作成功";
+    public static int CODE_SUCCESS = 0;
+    public static int CODE_FAILURE = -1;
+    public static String[] NOOP = new String[]{};
+
+    /**
+     * 处理状态:0: 成功, 1: 失败
+     */
+    @ApiModelProperty(value = "处理状态:0: 成功, 1: 失败", name = "code")
+    private int code;
+    /**
+     * 消息
+     */
+    @ApiModelProperty(value = "消息", name = "msg")
+    private String msg;
+    /**
+     * 返回数据
+     */
+    @ApiModelProperty(value = "返回数据", name = "data")
+    private T data;
+    /**
+     * 处理成功,并返回数据
+     *
+     * @param data 数据对象
+     * @return data
+     */
+    public static Result success(Object data) {
+        return new Result(CODE_SUCCESS, SUCCESS_MSG, data);
+    }
+    /**
+     * 处理成功
+     *
+     * @return data
+     */
+    public static Result success() {
+        return new Result(CODE_SUCCESS, SUCCESS_MSG, NOOP);
+    }
+    /**
+     * 处理成功
+     *
+     * @param msg 消息
+     * @return data
+     */
+    public static Result success(String msg) {
+        return new Result(CODE_SUCCESS, msg, NOOP);
+    }
+    /**
+     * 处理成功
+     *
+     * @param msg  消息
+     * @param data 数据对象
+     * @return data
+     */
+    public static Result success(String msg, Object data) {
+        return new Result(CODE_SUCCESS, msg, data);
+    }
+    /**
+     * 处理失败,并返回数据(一般为错误信息)
+     *
+     * @param code 错误代码
+     * @param msg  消息
+     * @return data
+     */
+    public static Result failure(int code, String msg) {
+        return new Result(code, msg, NOOP);
+    }
+    /**
+     * 处理失败
+     *
+     * @param msg 消息
+     * @return data
+     */
+    public static Result failure(String msg) {
+        return failure(CODE_FAILURE, msg);
+    }
+
+    @Override
+    public String toString() {
+        return "JsonResult [code=" + code + ", msg=" + msg + ", data="
+                + data + "]";
+    }
+}

+ 148 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/util/ResultJson.java

@@ -0,0 +1,148 @@
+package com.fdkankan.common.util;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ResultJson implements Serializable {
+
+	private static final long serialVersionUID = 2719931935414658118L;
+
+	private final Integer status;
+
+	private final String message;
+
+//	@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
+//	@JsonInclude(value = Include.NON_NULL)
+
+	private final Object data;
+
+	@JsonInclude(value = Include.NON_EMPTY)
+//	@JsonInclude(value = Include.NON_NULL)
+	@JSONField(serialize = false)
+	private final String[] exceptions;
+
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+	private final Date timestamp;
+
+	public ResultJson(Integer status, String message) {
+
+		super();
+		this.status = status;
+		this.message = message;
+		this.data = null;
+		this.timestamp = addTime();
+		this.exceptions = null;
+
+	}
+
+
+
+	
+	public ResultJson(Integer status, Object data) {
+
+		super();
+
+		this.status = status;
+		this.message = null;
+
+		this.data = data;
+		this.timestamp = addTime();
+		this.exceptions = null;
+
+	}
+	
+
+
+	public ResultJson(Integer status, String message, String key, Object value) {
+
+		super();
+
+		this.status = status;
+
+		this.message = message;
+
+		Map<String, Object> map = new HashMap<String, Object>();
+
+		if (key == null || ("").equals(key)) {
+			map.put("key", value);
+		} else {
+			map.put(key, value);
+		}
+
+		this.data = map;
+
+		this.timestamp = addTime();
+		this.exceptions = null;
+
+	}
+
+	public ResultJson(Integer status, Throwable ex) {
+
+		super();
+
+		this.status = status;
+		this.message = ex.getMessage();
+		this.data = null;
+		StackTraceElement[] stackTeanceElement = ex.getStackTrace();
+		this.exceptions = new String[stackTeanceElement.length];
+		for (int i = 0; i < stackTeanceElement.length; i++) {
+			this.exceptions[i] = stackTeanceElement[i].toString();
+		}
+		this.timestamp = addTime();
+	}
+
+	public ResultJson(Integer status, String message, Throwable ex) {
+
+		super();
+
+		this.status = status;
+
+		this.message = message;
+
+		this.data = null;
+
+		StackTraceElement[] stackTeanceElement = ex.getStackTrace();
+		this.exceptions = new String[stackTeanceElement.length];
+		for (int i = 0; i < stackTeanceElement.length; i++) {
+			this.exceptions[i] = stackTeanceElement[i].toString();
+		}
+
+		this.timestamp = addTime();
+
+	}
+
+	public Integer getStatus() {
+		return status;
+	}
+
+	public String getMessage() {
+		return message;
+	}
+
+	public Object getData() {
+		return data;
+	}
+
+	public String[] getExceptions() {
+		return exceptions;
+	}
+
+	public Date getTimestamp() {
+		return timestamp;
+	}
+
+	public Date addTime(){
+		Calendar nowTime= Calendar.getInstance();
+        nowTime.add(Calendar.MINUTE,15);
+        Date time = nowTime.getTime();
+        return time;
+	}
+}

+ 218 - 0
4dkankan-user-common/src/main/java/com/fdkankan/common/util/SnowFlakeUUidUtils.java

@@ -0,0 +1,218 @@
+package com.fdkankan.common.util;
+
+import lombok.extern.log4j.Log4j2;
+import org.apache.commons.lang3.StringUtils;
+
+import java.lang.management.ManagementFactory;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * 2 * @Author: Abner
+ * 3 * @Date: 2020/12/9 16:07
+ * 4
+ */
+@Log4j2
+public class SnowFlakeUUidUtils {
+
+    // 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动)
+    //起始标记点
+    private final static long twepoch = 1288834974657L;
+    // 机器标识位数
+    private final static long workerIdBits = 5L;
+    // 数据中心标识位数
+    private final static long datacenterIdBits = 5L;
+    // 机器ID最大值
+    private final static long maxWorkerId = -1L ^ (-1L << workerIdBits);
+    // 数据中心ID最大值
+    private final static long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
+    // 毫秒内自增位
+    private final static long sequenceBits = 12L;
+    // 机器ID偏左移12位
+    private final static long workerIdShift = sequenceBits;
+    // 数据中心ID左移17位
+    private final static long datacenterIdShift = sequenceBits + workerIdBits;
+    // 时间毫秒左移22位
+    private final static long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
+
+    private final static long sequenceMask = -1L ^ (-1L << sequenceBits);
+
+    private final static Lock myLock = new ReentrantLock();
+    /* 上次生产id时间戳 */
+    private static long lastTimestamp = -1L;
+    // 0,并发控制
+    private long sequence = 0L;
+
+    private final long workerId;
+    // 数据标识id部分
+    private final long datacenterId;
+
+    private static volatile SnowFlakeUUidUtils snowFlakeUUidUtils;
+
+
+    private static SnowFlakeUUidUtils getSingleInstance(Long workerId, Long datacenterId){
+        if(null == snowFlakeUUidUtils){
+            synchronized (SnowFlakeUUidUtils.class){
+                if(null == snowFlakeUUidUtils){
+                    if(null != workerId && null != datacenterId){
+                        snowFlakeUUidUtils = new SnowFlakeUUidUtils(workerId , datacenterId);
+                    }else{
+                        snowFlakeUUidUtils = new SnowFlakeUUidUtils();
+                    }
+                }
+            }
+        }
+        return snowFlakeUUidUtils;
+    }
+
+    /**
+     * @param workerId 自定义的应用所在的服务器的机器ID,使用默认读取本机则无需传,传个NULL即可
+     * @param datacenterId 自定义的应用所在的服务器的数据中心ID,使用默认读取本机则无需传,传个NULL即可
+     * @param preStr 自定义的ID前缀
+     * **/
+    public static String generaUUid(Long workerId, Long datacenterId , String preStr){
+        StringBuilder resultId = new StringBuilder();
+        SnowFlakeUUidUtils snowFlakeUUidUtils = getSingleInstance(workerId , datacenterId);
+        if(StringUtils.isNotBlank(preStr)){
+            return resultId.append(preStr).append(snowFlakeUUidUtils.nextId()).toString();
+        }else{
+            return resultId.append(snowFlakeUUidUtils.nextId()).toString();
+        }
+    }
+
+    public SnowFlakeUUidUtils(){
+        this.datacenterId = getDatacenterId(maxDatacenterId);
+        this.workerId = getMaxWorkerId(datacenterId, maxWorkerId);
+    }
+    /**
+     * @param workerId
+     *            工作机器ID
+     * @param datacenterId
+     *            序列号
+     */
+    public SnowFlakeUUidUtils(long workerId, long datacenterId) {
+        if (workerId > maxWorkerId || workerId < 0) {
+            throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
+        }
+        if (datacenterId > maxDatacenterId || datacenterId < 0) {
+            throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
+        }
+        this.workerId = workerId;
+        this.datacenterId = datacenterId;
+    }
+    /**
+     * 获取下一个ID
+     * 线程安全
+     * @return NULL 抢锁失败,需要重新调用
+     *         数字串 抢锁成功,则生成20位的数字串
+     */
+    public  Long nextId() {
+        try {
+
+            if(myLock.tryLock(700 , TimeUnit.MILLISECONDS)){
+                try {
+                    long timestamp = timeGen();
+                    if (timestamp < lastTimestamp) {
+                        throw new RuntimeException(String.format("Clock moved backwards.  Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
+                    }
+
+                    if (lastTimestamp == timestamp) {
+                        // 当前毫秒内,则+1
+                        sequence = (sequence + 1) & sequenceMask;
+                        if (sequence == 0) {
+                            // 当前毫秒内计数满了,则等待下一秒
+                            timestamp = tilNextMillis(lastTimestamp);
+                        }
+                    } else {
+                        sequence = 0L;
+                    }
+                    lastTimestamp = timestamp;
+                    // ID偏移组合生成最终的ID,并返回ID
+                    Long nextId = ((timestamp - twepoch) << timestampLeftShift)
+                            | (datacenterId << datacenterIdShift)
+                            | (workerId << workerIdShift) | sequence;
+
+                    return nextId;
+                }catch (Exception e){
+                    log.info("生成UUID抢锁失败:{}" , e);
+                }finally {
+                    myLock.unlock();
+                }
+            }else{
+                return null;
+            }
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+        return null;
+
+    }
+
+    private long tilNextMillis(final long lastTimestamp) {
+        long timestamp = this.timeGen();
+        while (timestamp <= lastTimestamp) {
+            timestamp = this.timeGen();
+        }
+        return timestamp;
+    }
+
+    private long timeGen() {
+        return System.currentTimeMillis();
+    }
+
+    /**
+     * <p>
+     * 获取 maxWorkerId
+     * </p>
+     */
+    protected static long getMaxWorkerId(long datacenterId, long maxWorkerId) {
+        StringBuffer mpid = new StringBuffer();
+        mpid.append(datacenterId);
+        String name = ManagementFactory.getRuntimeMXBean().getName();
+        if (!name.isEmpty()) {
+            /*
+             * GET jvmPid
+             */
+            mpid.append(name.split("@")[0]);
+        }
+        /*
+         * MAC + PID 的 hashcode 获取16个低位
+         */
+        return (mpid.toString().hashCode() & 0xffff) % (maxWorkerId + 1);
+    }
+
+    /**
+     * <p>
+     * 数据标识id部分
+     * </p>
+     */
+    protected static long getDatacenterId(long maxDatacenterId) {
+        long id = 0L;
+        try {
+            InetAddress ip = InetAddress.getLocalHost();
+            NetworkInterface network = NetworkInterface.getByInetAddress(ip);
+            if (network == null) {
+                id = 1L;
+            } else {
+                byte[] mac = network.getHardwareAddress();
+                id = ((0x000000FF & (long) mac[mac.length - 1])
+                        | (0x0000FF00 & (((long) mac[mac.length - 2]) << 8))) >> 6;
+                id = id % (maxDatacenterId + 1);
+            }
+        } catch (Exception e) {
+            System.out.println(" getDatacenterId: " + e.getMessage());
+        }
+        return id;
+    }
+
+    public static void main(String[] args) {
+        for(int i = 0; i < 20; i++){
+
+            System.out.println(SnowFlakeUUidUtils.generaUUid(null, null, null));
+        }
+    }
+
+}

+ 26 - 0
4dkankan-user-dao/pom.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>fdkankan</artifactId>
+        <groupId>com.fdkankan</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>4dkankan-user-dao</artifactId>
+    <version>1.0.0</version>
+    <packaging>jar</packaging>
+
+
+    <dependencies>
+
+        <dependency>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-user-domain</artifactId>
+        </dependency>
+    </dependencies>
+
+
+</project>

+ 23 - 0
4dkankan-user-dao/src/main/java/com/fdkankan/dao/backend/DepartmentRepository.java

@@ -0,0 +1,23 @@
+package com.fdkankan.dao.backend;
+
+import com.fdkankan.domain.backend.DepartmentEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+
+/**
+ * Created by Hb_zzZ on 2020/2/27.
+ */
+@Mapper
+public interface DepartmentRepository extends IBaseRepository<DepartmentEntity, String> {
+
+    @Select(value = "select d.* from t_department d where d.name = #{name} and is_delete = '0'")
+    DepartmentEntity findByName(@Param("name") String name);
+
+
+    @Select(value = "select id from t_department where name like concat('%', #{name}, '%') and is_delete = '0'")
+    List<String> findByNameLike(@Param("name") String name);
+}

+ 19 - 0
4dkankan-user-dao/src/main/java/com/fdkankan/dao/backend/IBaseRepository.java

@@ -0,0 +1,19 @@
+package com.fdkankan.dao.backend;
+
+import com.fdkankan.common.model.BaseModel;
+import tk.mybatis.mapper.common.BaseMapper;
+import tk.mybatis.mapper.common.ConditionMapper;
+import tk.mybatis.mapper.common.IdsMapper;
+import tk.mybatis.mapper.common.special.InsertListMapper;
+
+import java.io.Serializable;
+
+/**
+ * Created by owen on 2020/2/18 0018 11:27
+ */
+
+public interface IBaseRepository<T extends BaseModel, ID extends Serializable> extends BaseMapper<T>,
+        ConditionMapper<T>,
+        IdsMapper<T>,
+        InsertListMapper<T> {
+}

+ 11 - 0
4dkankan-user-dao/src/main/java/com/fdkankan/dao/backend/ResourceRepository.java

@@ -0,0 +1,11 @@
+package com.fdkankan.dao.backend;
+
+import com.fdkankan.domain.backend.ResourceEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * Created by owen on 2020/2/18 0018 11:13
+ */
+@Mapper
+public interface ResourceRepository extends IBaseRepository<ResourceEntity, String> {
+}

+ 29 - 0
4dkankan-user-dao/src/main/java/com/fdkankan/dao/backend/RoleRepository.java

@@ -0,0 +1,29 @@
+package com.fdkankan.dao.backend;
+
+import com.fdkankan.domain.backend.RoleEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+
+import java.math.BigInteger;
+import java.util.Set;
+
+/**
+ * Created by owen on 2020/2/18 0018 11:13
+ */
+@Mapper
+public interface RoleRepository extends IBaseRepository<RoleEntity, String> {
+
+
+    @Select(value = "insert into t_role_resource (role_id, resource_id) values (#{roleId}, #{resourceId});")
+    void saveRoleResource(String roleId, String resourceId);
+
+    @Select(value = "delete from t_role_resource where role_id=#{roleId}")
+    void deleteRoleResource(String roleId);
+
+    @Select(value = "select resource_id from t_role_resource where role_id= #{userId}")
+    Set<String> findRoleResourceByRoleId(String userId);
+
+    @Select("select a.id, a.role_name as roleName, a.role_desc as roleDesc, a.role_key as roleKey, a.sort" +
+            " from t_role a left join t_user_role b on a.id = b.role_id where b.user_id = #{id}")
+    RoleEntity findByUserId(String id);
+}

+ 40 - 0
4dkankan-user-dao/src/main/java/com/fdkankan/dao/backend/UserRepository.java

@@ -0,0 +1,40 @@
+package com.fdkankan.dao.backend;
+
+import com.fdkankan.dao.backend.provider.UserProvider;
+import com.fdkankan.domain.backend.UserEntity;
+import com.fdkankan.domain.dto.request.UserRequest;
+import com.fdkankan.domain.dto.response.UserResponse;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.SelectProvider;
+
+import java.math.BigInteger;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Created by owen on 2020/2/18 0018 11:13
+ */
+@Mapper
+public interface UserRepository extends IBaseRepository<UserEntity, String> {
+
+    @Select(value = "delete from t_user_role where user_id=#{userId}")
+    void deleteUserRole(String userId);
+
+    @Select(value = "select * from t_user where user_name= #{userName}")
+    UserEntity findByUserName(String userName);
+
+    @Select(value = "select role_id from t_user_role where user_id= #{userId}")
+    Set<String> findUserRoleByUserId(String userId);
+
+    @Select(value = "select id from t_user where real_name like concat('%', #{realName}, '%')")
+    List<String> findUserIdByRealName(String realName);
+
+    @SelectProvider(type = UserProvider.class, method = "findAllBySearchKey")
+    List<UserResponse> findAllBySearchKey(UserRequest param);
+
+    @Select(value = "SELECT role_key FROM `t_role` a LEFT JOIN `t_user_role` b ON a.`id` = b.role_id WHERE b.user_id = #{userId} LIMIT 1")
+    String findRoleKey(String userId);
+
+}

+ 11 - 0
4dkankan-user-dao/src/main/java/com/fdkankan/dao/backend/UserRoleRepository.java

@@ -0,0 +1,11 @@
+package com.fdkankan.dao.backend;
+
+import com.fdkankan.domain.backend.UserRoleEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * Created by Hb_zzZ on 2021/1/4.
+ */
+@Mapper
+public interface UserRoleRepository extends IBaseRepository<UserRoleEntity, String>{
+}

+ 32 - 0
4dkankan-user-dao/src/main/java/com/fdkankan/dao/backend/provider/UserProvider.java

@@ -0,0 +1,32 @@
+package com.fdkankan.dao.backend.provider;
+
+import com.fdkankan.domain.dto.request.UserRequest;
+import com.github.pagehelper.util.StringUtil;
+
+/**
+ * Created by Hb_zzZ on 2020/3/3.
+ */
+public class UserProvider {
+
+    public String findAllBySearchKey(UserRequest param){
+        StringBuffer sql = new StringBuffer("SELECT a.id, a.nick_name as nickName, a.create_time as createTime, " +
+                " REPLACE ( a.user_name, SUBSTR(a.user_name,4,4), '****') AS userName," +
+                " a.head, a.create_time, b.name as departmentName, d.role_name as roleName," +
+                " a.department_id as departmentId, d.id as roleId " +
+                "FROM `t_user` a LEFT JOIN `t_department` b ON a.department_id = b.id " +
+                "LEFT JOIN `t_user_role` c ON a.id = c.user_id " +
+                "LEFT JOIN `t_role` d ON c.role_id = d.id where a.is_delete = '0' ");
+        if(StringUtil.isNotEmpty(param.getNickName())){
+            sql.append(" and a.nick_name like CONCAT('%', #{nickName}, '%') ");
+        }
+        if(StringUtil.isNotEmpty(param.getUserName())){
+            sql.append(" and a.user_name like CONCAT('%', #{userName}, '%') ");
+        }
+        if(StringUtil.isNotEmpty(param.getDepartmentId())){
+            sql.append(" and a.department_id = #{departmentId}");
+        }
+        sql.append(" ORDER BY a.create_time DESC");
+        return sql.toString();
+    }
+
+}

+ 27 - 0
4dkankan-user-domain/pom.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>fdkankan</artifactId>
+        <groupId>com.fdkankan</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>4dkankan-user-domain</artifactId>
+    <version>1.0.0</version>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <!--4dkankan-user-common依赖-->
+        <dependency>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-user-common</artifactId>
+        </dependency>
+
+
+    </dependencies>
+
+
+</project>

+ 32 - 0
4dkankan-user-domain/src/main/java/com/fdkankan/domain/backend/DepartmentEntity.java

@@ -0,0 +1,32 @@
+package com.fdkankan.domain.backend;
+
+import com.fdkankan.common.model.BaseModel;
+import lombok.Data;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+/**
+ * Created by Hb_zzZ on 2020/2/27.
+ */
+@Data
+@Entity
+@Table(name = "t_department")
+public class DepartmentEntity extends BaseModel implements Serializable {
+
+    @Column
+    private String parentId;
+
+    /**
+     * 部门代号
+     */
+    private String num;
+
+    /**
+     * 部门名称
+     */
+    private String name;
+
+}

+ 46 - 0
4dkankan-user-domain/src/main/java/com/fdkankan/domain/backend/ResourceEntity.java

@@ -0,0 +1,46 @@
+package com.fdkankan.domain.backend;
+
+import com.fdkankan.common.model.BaseModel;
+import io.swagger.models.auth.In;
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "t_resource")
+@Data
+public class ResourceEntity extends BaseModel implements Serializable {
+
+    /**
+     *
+     */
+    private static final long serialVersionUID = -293343757324080501L;
+
+    @Column(length = 50)
+    private String name;
+
+    // 描述
+    @Column(name = "description")
+    private String description;
+
+    @Column(name = "url")
+    private String url;
+
+    @Column(length = 10)
+    private String icon;
+
+    @Column(name = "resource_key")
+    private String resourceKey;
+
+    // 前端需要传menu、button
+    @Column(columnDefinition = "enum('menu','button')")
+    private String resourceType;
+
+    private Integer sort;
+
+    @Column(name = "parent_id")
+    private String parentId;
+
+
+}

+ 26 - 0
4dkankan-user-domain/src/main/java/com/fdkankan/domain/backend/RoleEntity.java

@@ -0,0 +1,26 @@
+package com.fdkankan.domain.backend;
+
+import com.fdkankan.common.model.BaseModel;
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Data
+@Entity
+@Table(name = "t_role")
+public class RoleEntity extends BaseModel implements Serializable {
+
+    private static final long serialVersionUID = -8093446477843493946L;
+
+    @Column(length = 50)
+    private String roleName;
+
+    // 描述
+    private String roleDesc;
+
+    private String roleKey;
+
+    private Integer sort;
+
+}

+ 37 - 0
4dkankan-user-domain/src/main/java/com/fdkankan/domain/backend/UserEntity.java

@@ -0,0 +1,37 @@
+package com.fdkankan.domain.backend;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fdkankan.common.model.BaseModel;
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Data
+@Entity
+@Table(name = "t_user")
+public class UserEntity extends BaseModel implements Serializable {
+
+    private static final long serialVersionUID = -853504493430501564L;
+
+    @Column(length = 50)
+    private String userName;
+
+    @JSONField(serialize = false)
+    @Column(length = 100)
+    private String password;
+
+    @Column(length = 50)
+    private String nickName; // 真实姓名
+
+    @Column(length = 1)
+    private int status; // 0:启用  1:停用
+
+    @Column
+    private String departmentId; //部门
+
+    @Column
+    private String head;
+
+
+}

+ 24 - 0
4dkankan-user-domain/src/main/java/com/fdkankan/domain/backend/UserRoleEntity.java

@@ -0,0 +1,24 @@
+package com.fdkankan.domain.backend;
+
+import com.fdkankan.common.model.BaseModel;
+import lombok.Data;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+/**
+ * Created by Hb_zzZ on 2021/1/4.
+ */
+@Data
+@Entity
+@Table(name = "t_user_role")
+public class UserRoleEntity extends BaseModel implements Serializable {
+
+    @Column
+    private String userId;
+
+    @Column
+    private String roleId;
+}

+ 22 - 0
4dkankan-user-domain/src/main/java/com/fdkankan/domain/dto/request/DepartmentRequest.java

@@ -0,0 +1,22 @@
+package com.fdkankan.domain.dto.request;
+
+import com.fdkankan.common.model.PageDto;
+import lombok.Data;
+
+/**
+ * Created by Hb_zzZ on 2020/2/27.
+ */
+@Data
+public class DepartmentRequest extends PageDto {
+
+    private String id;
+
+    private String parentId;
+
+    private String num;
+
+    private String name;
+
+    private String departmentId;
+
+}

+ 32 - 0
4dkankan-user-domain/src/main/java/com/fdkankan/domain/dto/request/OperationRequest.java

@@ -0,0 +1,32 @@
+package com.fdkankan.domain.dto.request;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * Created by Hb_zzZ on 2021/1/15.
+ */
+@Data
+public class OperationRequest {
+
+    private String operateContent;
+
+    private Date operateTime;
+
+    private String operateType;
+
+    private String operatorCompanyId;
+
+    private String operatorCompanyName;
+
+    private String operatorId;
+
+    private String operatorName;
+
+    private String operatorPhone;
+
+    private String operatorRoleId;
+
+    private String operatorRoleName;
+}

+ 29 - 0
4dkankan-user-domain/src/main/java/com/fdkankan/domain/dto/request/ResourceRequest.java

@@ -0,0 +1,29 @@
+package com.fdkankan.domain.dto.request;
+
+import lombok.Data;
+
+/**
+ * Created by owen on 2020/2/19 0019 11:36
+ */
+@Data
+public class ResourceRequest {
+
+    private String id;
+
+    private String name;
+
+    private String description;
+
+    private String url;
+
+    private String icon;
+
+    private String resourceKey;
+
+    // 前端需要传menu、button
+    private String resourceType; // menu/button
+
+    private int sort;
+
+    private String parentId;
+}

+ 28 - 0
4dkankan-user-domain/src/main/java/com/fdkankan/domain/dto/request/RoleRequest.java

@@ -0,0 +1,28 @@
+package com.fdkankan.domain.dto.request;
+
+import com.fdkankan.common.model.PageDto;
+import lombok.Data;
+
+import java.util.Set;
+
+/**
+ * Created by owen on 2020/2/18 0018 17:09
+ */
+@Data
+public class RoleRequest extends PageDto{
+
+    private String id;
+
+    private String roleName;
+
+    // 描述
+    private String roleDesc;
+
+    private String roleKey;
+
+    // 排序
+    private Integer sort;
+
+    // 资源id
+    private Set<String> resources;
+}

+ 34 - 0
4dkankan-user-domain/src/main/java/com/fdkankan/domain/dto/request/UserRequest.java

@@ -0,0 +1,34 @@
+package com.fdkankan.domain.dto.request;
+
+import com.fdkankan.common.model.PageDto;
+import lombok.Data;
+
+/**
+ * Created by owen on 2020/2/18 0018 17:09
+ */
+@Data
+public class UserRequest extends PageDto{
+
+    private String id;
+
+    private String userName;
+
+    private String password;
+
+    private String oldPassword;
+
+    private String confirmPwd;
+
+    private String nickName;
+
+    private String departmentId;
+
+    private String roleId;
+
+    private String searchKey;
+
+    private String code;
+
+    private String key;
+
+}

+ 65 - 0
4dkankan-user-domain/src/main/java/com/fdkankan/domain/dto/response/ResponseCamera.java

@@ -0,0 +1,65 @@
+package com.fdkankan.domain.dto.response;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+public class ResponseCamera implements Serializable {
+
+    private static final long serialVersionUID = -8445289048065283322L;
+
+    @ApiModelProperty(value = "id", name = "id")
+    private String id;
+
+    @ApiModelProperty(value = "激活时间", name = "activatedTime")
+    private String activatedTime;
+
+    @ApiModelProperty(value = "相机的Mac地址", name = "childName")
+    private String childName;
+
+    @ApiModelProperty(value = "sn码", name = "snCode")
+    private String snCode;
+
+    /**
+     * 相机密码
+     */
+    @ApiModelProperty(value = "相机密码", name = "childPassword")
+    private String childPassword;
+    /**
+     * wifi名称
+     */
+    @ApiModelProperty(value = "wifi名称", name = "wifiName")
+    private String wifiName;
+    /**
+     * wifi密码
+     */
+    @ApiModelProperty(value = "wifi密码", name = "wifiPassword")
+    private String wifiPassword;
+
+    /**
+     * 部门表的id
+     */
+    @ApiModelProperty(value = "部门id", name = "departmentId")
+    private String departmentId;
+
+    /**
+     * 部门名称
+     */
+    @ApiModelProperty(value = "部门名称", name = "departmentName")
+    private String departmentName;
+
+    /**
+     * 场景数量
+     */
+    @ApiModelProperty(value = "场景数量", name = "sceneCount")
+    private Integer sceneCount;
+
+    /**
+     * 最后拍摄时间
+     */
+    @ApiModelProperty(value = "最后拍摄时间", name = "lastTime")
+    private String lastTime;
+}

+ 33 - 0
4dkankan-user-domain/src/main/java/com/fdkankan/domain/dto/response/UserResponse.java

@@ -0,0 +1,33 @@
+package com.fdkankan.domain.dto.response;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Created by Hb_zzZ on 2020/2/28.
+ */
+@Data
+public class UserResponse implements Serializable {
+
+    private String id;
+
+    private String userName;
+
+    private String password;
+
+    private String nickName; // 真实姓名
+
+    private String roleName;
+
+    private String roleId;
+
+    private String head;
+
+    private String departmentName; //部门
+
+    private String departmentId; //部门
+
+    private Date createTime;
+}

+ 30 - 0
4dkankan-user-service/pom.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>fdkankan</artifactId>
+        <groupId>com.fdkankan</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>4dkankan-user-service</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0.0</version>
+
+    <dependencies>
+        <dependency>
+        <groupId>com.fdkankan</groupId>
+        <artifactId>4dkankan-user-common</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-user-dao</artifactId>
+        </dependency>
+
+    </dependencies>
+
+
+</project>

+ 157 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/BaseServiceImpl.java

@@ -0,0 +1,157 @@
+package com.fdkankan.service;
+
+import com.fdkankan.common.util.SnowFlakeUUidUtils;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.fdkankan.common.model.BaseModel;
+import com.fdkankan.dao.backend.IBaseRepository;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.StringUtils;
+import tk.mybatis.mapper.entity.Condition;
+
+import java.io.Serializable;
+import java.lang.reflect.ParameterizedType;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created by owen on 2020/2/18 0018 11:22
+ */
+@Transactional
+public abstract class BaseServiceImpl<T extends BaseModel, ID extends Serializable> implements IBaseService<T, ID> {
+
+    public abstract IBaseRepository<T, ID> getBaseMapper();
+
+    private Class<T> entityClass;
+
+    public BaseServiceImpl(){
+        ParameterizedType pt = (ParameterizedType) this.getClass().getGenericSuperclass();
+        entityClass = (Class<T>) pt.getActualTypeArguments()[0];
+    }
+
+    @Override
+    public T findById(ID id){
+        Condition condition = new Condition(entityClass);
+        condition.createCriteria().andEqualTo("id", id);
+        condition.and().andEqualTo("isDelete", "0");
+        List<T> ts = getBaseMapper().selectByCondition(condition);
+        if (ts != null && ts.size() > 0){
+            return ts.get(0);
+        }else{
+            return null;
+        }
+    }
+
+    @Override
+    public T findOne(T entity){
+        entity.setIsDelete("0");
+        return getBaseMapper().selectOne(entity);
+    }
+
+    @Override
+    public List<T> findAll(){
+        Condition condition = new Condition(entityClass);
+        condition.createCriteria().andEqualTo("isDelete", "0");
+        return getBaseMapper().selectByCondition(condition);
+    }
+
+    /**
+     * 根据主键字符串进行查询,类中只有存在一个带有@Id注解的字段
+     *
+     * @param ids 如 "1,2,3,4"
+     * @return
+     */
+    @Override
+    public List<T> findByIds(String ids){
+        return getBaseMapper().selectByIds(ids);
+    }
+
+    @Override
+    public long count(){
+        List<T> all = this.findAll();
+        if (all != null && all.size() > 0){
+            return all.size();
+        }
+        return 0;
+    }
+
+    @Override
+    public boolean exists(ID id){
+        return getBaseMapper().existsWithPrimaryKey(id);
+    }
+
+    @Override
+    public int save(T entity) {
+        entity.setId(SnowFlakeUUidUtils.generaUUid(null, null, null));
+        entity.setCreateTime(new Date());
+        entity.setUpdateTime(new Date());
+        entity.setIsDelete("0");
+        return getBaseMapper().insertSelective(entity);
+    }
+
+    @Override
+    public int update(T entity) {
+        entity.setUpdateTime(new Date());
+        return getBaseMapper().updateByPrimaryKeySelective(entity);
+    }
+
+    @Override
+    public int updateAll(T entity) {
+        entity.setUpdateTime(new Date());
+        return getBaseMapper().updateByPrimaryKey(entity);
+    }
+
+    @Override
+    public int deleteById(ID id) {
+        return getBaseMapper().deleteByPrimaryKey(id);
+    }
+
+    @Override
+    public int deleteByIds(String ids){
+        return getBaseMapper().deleteByIds(ids);
+    }
+
+    @Override
+    public int delete(T entity){
+        return getBaseMapper().delete(entity);
+    }
+
+    public List<T> findAll(Condition condition){
+        condition.and().andEqualTo("isDelete", "0");
+        return getBaseMapper().selectByCondition(condition);
+    }
+
+    public List<T> findAll(Condition condition, String orderBy){
+        condition.and().andEqualTo("isDelete", "0");
+        if (!StringUtils.isEmpty(orderBy)){
+            PageHelper.orderBy(orderBy);
+        }
+        return getBaseMapper().selectByCondition(condition);
+    }
+
+    public PageInfo<T> findAll(int pageNum, int pageSize){
+        PageHelper.startPage(pageNum, pageSize);
+        return new PageInfo<>(this.findAll());
+    }
+
+    public PageInfo<T> findAll(int pageNum, int pageSize, String orderBy){
+        PageHelper.startPage(pageNum, pageSize);
+        if (!StringUtils.isEmpty(orderBy)){
+            PageHelper.orderBy(orderBy);
+        }
+        return new PageInfo<>(this.findAll());
+    }
+
+    public PageInfo<T> findAll(Condition condition, int pageNum, int pageSize){
+        PageHelper.startPage(pageNum, pageSize);
+        return new PageInfo<>(this.findAll(condition));
+    }
+
+    public PageInfo<T> findAll(Condition condition, int pageNum, int pageSize, String orderBy){
+        PageHelper.startPage(pageNum, pageSize);
+        if (!StringUtils.isEmpty(orderBy)){
+            PageHelper.orderBy(orderBy);
+        }
+        return new PageInfo<>(this.findAll(condition));
+    }
+}

+ 49 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/IBaseService.java

@@ -0,0 +1,49 @@
+package com.fdkankan.service;
+
+import com.github.pagehelper.PageInfo;
+import org.springframework.data.domain.Page;
+import tk.mybatis.mapper.entity.Condition;
+
+
+import java.io.Serializable;
+import java.util.List;
+
+public interface IBaseService<T, ID extends Serializable> {
+
+    public abstract T findById(ID id);
+
+    public abstract T findOne(T entity);
+
+    public abstract List<T> findByIds(String ids);
+
+    public abstract long count();
+
+    public abstract boolean exists(ID id);
+
+    public abstract int save(T entity);
+
+    public abstract int update(T entity);
+
+    public abstract int updateAll(T entity);
+
+    public abstract int deleteById(ID id);
+
+    public abstract int deleteByIds(String ids);
+
+    public abstract int delete(T entity);
+
+    public abstract List<T> findAll(Condition condition, String orderBy);
+
+    public abstract List<T> findAll(Condition condition);
+
+    public abstract List<T> findAll();
+
+    public abstract PageInfo<T> findAll(int pageNum, int pageSize);
+
+    public abstract PageInfo<T> findAll(int pageNum, int pageSize, String orderBy);
+
+    public abstract PageInfo<T> findAll(Condition condition, int pageNum, int pageSize);
+
+    public abstract PageInfo<T> findAll(Condition condition, int pageNum, int pageSize, String orderBy);
+
+}

+ 16 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/backend/DepartmentService.java

@@ -0,0 +1,16 @@
+package com.fdkankan.service.backend;
+
+import com.fdkankan.domain.backend.DepartmentEntity;
+import com.fdkankan.service.IBaseService;
+
+import java.util.List;
+
+/**
+ * Created by Hb_zzZ on 2020/2/27.
+ */
+public interface DepartmentService extends IBaseService<DepartmentEntity, String> {
+
+    DepartmentEntity findByName(String name);
+
+    List<String> findByNameLike(String name);
+}

+ 24 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/backend/ResourceService.java

@@ -0,0 +1,24 @@
+package com.fdkankan.service.backend;
+
+import com.fdkankan.domain.backend.ResourceEntity;
+import com.fdkankan.domain.backend.UserEntity;
+import com.fdkankan.service.backend.dto.ResourceTree;
+import com.fdkankan.service.IBaseService;
+
+import java.util.List;
+
+/**
+ * Created by owen on 2020/2/19 0019 10:22
+ */
+public interface ResourceService extends IBaseService<ResourceEntity, String> {
+
+    List<ResourceTree> getResourcesTreeByUserMenu(UserEntity userEntity) throws Exception;
+
+    List<ResourceTree> getResourcesTreeByUserPermission(UserEntity userEntity) throws Exception;
+
+    List<ResourceTree> getTree() throws Exception;
+
+    List<ResourceEntity> getResourcesByUserPermission(UserEntity userEntity);
+
+//    public boolean existsByResourceKey(String resourceKey) throws Exception;
+}

+ 21 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/backend/RoleService.java

@@ -0,0 +1,21 @@
+package com.fdkankan.service.backend;
+
+import com.fdkankan.domain.backend.RoleEntity;
+import com.fdkankan.service.IBaseService;
+
+import java.math.BigInteger;
+import java.util.Set;
+
+/**
+ * Created by owen on 2020/2/18 0018 11:36
+ */
+public interface RoleService extends IBaseService<RoleEntity, String> {
+
+    void saveRoleResource(String roleId, String resourceId);
+
+    void deleteRoleResource(String roleId);
+
+    Set<String> findRoleResourceByRoleId(String id);
+
+    RoleEntity findByUserId(String id);
+}

+ 10 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/backend/UserRoleService.java

@@ -0,0 +1,10 @@
+package com.fdkankan.service.backend;
+
+import com.fdkankan.domain.backend.UserRoleEntity;
+import com.fdkankan.service.IBaseService;
+
+/**
+ * Created by Hb_zzZ on 2021/1/4.
+ */
+public interface UserRoleService extends IBaseService<UserRoleEntity, String> {
+}

+ 32 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/backend/UserService.java

@@ -0,0 +1,32 @@
+package com.fdkankan.service.backend;
+
+import com.fdkankan.domain.backend.UserEntity;
+import com.fdkankan.domain.dto.request.UserRequest;
+import com.fdkankan.domain.dto.response.UserResponse;
+import com.fdkankan.service.IBaseService;
+
+import java.math.BigInteger;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Created by owen on 2020/2/18 0018 11:36
+ */
+public interface UserService extends IBaseService<UserEntity, String> {
+
+//    void saveUserRole(Long userId, Long roleId);
+
+    void deleteUserRole(String userId);
+
+    UserEntity findByUserName(String userName);
+
+    Set<String> findUserRoleByUserId(String userId);
+
+    List<String> findUserIdByRealName(String realName);
+
+    List<UserResponse> findAllBySearchKey(UserRequest param);
+
+    String findRoleKey(String userId);
+
+
+}

+ 78 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/backend/dto/DepartmentTree.java

@@ -0,0 +1,78 @@
+package com.fdkankan.service.backend.dto;
+
+import io.swagger.models.auth.In;
+
+import java.util.List;
+
+public class DepartmentTree {
+
+    private String id;
+
+    private String name;
+
+    private String parentId;
+
+    private String num;
+
+    private List<DepartmentTree> children;
+
+    private int level;
+
+    private boolean checked = false;
+
+    public void setChecked(boolean checked) {
+        this.checked = checked;
+    }
+
+    public int getLevel() {
+        return level;
+    }
+
+    public boolean isChecked() {
+        return checked;
+    }
+
+    public void setLevel(int level) {
+        this.level = level;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(String parentId) {
+        this.parentId = parentId;
+    }
+
+    public String getNum() {
+        return num;
+    }
+
+    public void setNum(String num) {
+        this.num = num;
+    }
+
+    public List<DepartmentTree> getChildren() {
+        return children;
+    }
+
+    public void setChildren(List<DepartmentTree> children) {
+        this.children = children;
+    }
+}

+ 138 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/backend/dto/ResourceTree.java

@@ -0,0 +1,138 @@
+package com.fdkankan.service.backend.dto;
+
+import java.util.List;
+
+public class ResourceTree {
+
+    private String id;
+
+    private String name;
+
+    private String parentId;
+
+    private boolean checked = false;
+
+    private boolean spread = false;
+
+    private String isHeader = "0";
+
+    private String url;
+
+    private String icon;
+
+    private String resourceKey;
+
+    private String resourceType;
+
+    private String order = "1";
+
+    private List<ResourceTree> children;
+
+    private int level;
+
+    public String getId() {
+        return id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public List<ResourceTree> getChildren() {
+        return children;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setChildren(List<ResourceTree> children) {
+        this.children = children;
+    }
+
+    public String getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(String parentId) {
+        this.parentId = parentId;
+    }
+
+    public boolean isChecked() {
+        return checked;
+    }
+
+    public void setChecked(boolean checked) {
+        this.checked = checked;
+        this.spread = checked;
+    }
+
+    public boolean isSpread() {
+        return spread;
+    }
+
+    public void setSpread(boolean spread) {
+        this.spread = spread;
+    }
+
+
+    public String getIsHeader() {
+        return isHeader;
+    }
+
+    public void setIsHeader(String isHeader) {
+        this.isHeader = isHeader;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getIcon() {
+        return icon;
+    }
+
+    public void setIcon(String icon) {
+        this.icon = icon;
+    }
+
+    public String getOrder() {
+        return order;
+    }
+
+    public void setOrder(String order) {
+        this.order = order;
+    }
+
+    public int getLevel() {
+        return level;
+    }
+
+    public void setLevel(int level) {
+        this.level = level;
+    }
+
+    public String getResourceType() {
+        return resourceType;
+    }
+
+    public void setResourceType(String resourceType) {
+        this.resourceType = resourceType;
+    }
+
+    public String getResourceKey() {
+        return resourceKey;
+    }
+
+    public void setResourceKey(String resourceKey) {
+        this.resourceKey = resourceKey;
+    }
+}

+ 20 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/backend/feign/CameraFeign.java

@@ -0,0 +1,20 @@
+package com.fdkankan.service.backend.feign;
+
+import com.fdkankan.common.util.Result;
+import com.fdkankan.domain.dto.request.DepartmentRequest;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+
+/**
+ * Created by Hb_zzZ on 2021/1/7.
+ */
+@FeignClient(value = "4dkankan-scene")
+public interface CameraFeign {
+
+    @PostMapping(value = "/api/scene/camera/findByDepartmentId", consumes = MediaType.APPLICATION_JSON_VALUE, produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
+    Result findByDepartmentId(@RequestBody DepartmentRequest param, @RequestHeader(name = "token", required = true) String token);
+
+}

+ 19 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/backend/feign/OperatorFeign.java

@@ -0,0 +1,19 @@
+package com.fdkankan.service.backend.feign;
+
+import com.fdkankan.domain.dto.request.OperationRequest;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+
+/**
+ * Created by Hb_zzZ on 2021/1/7.
+ */
+@FeignClient(value = "fbc-project-manager")
+public interface OperatorFeign {
+
+    @PostMapping(value = "/fcb/project/operation/addNew", consumes = MediaType.APPLICATION_JSON_VALUE, produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
+    void addNew(@RequestBody OperationRequest param, @RequestHeader(name = "token",required = true) String token);
+
+}

+ 38 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/backend/impl/DepartmentServiceImpl.java

@@ -0,0 +1,38 @@
+package com.fdkankan.service.backend.impl;
+
+import com.fdkankan.dao.backend.DepartmentRepository;
+import com.fdkankan.dao.backend.IBaseRepository;
+import com.fdkankan.domain.backend.DepartmentEntity;
+import com.fdkankan.service.BaseServiceImpl;
+import com.fdkankan.service.backend.DepartmentService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * Created by Hb_zzZ on 2020/2/27.
+ */
+@Service
+@Transactional
+public class DepartmentServiceImpl extends BaseServiceImpl<DepartmentEntity, String> implements DepartmentService {
+
+    @Autowired
+    private DepartmentRepository departmentRepository;
+
+    @Override
+    public IBaseRepository<DepartmentEntity, String> getBaseMapper() {
+        return this.departmentRepository;
+    }
+
+    @Override
+    public DepartmentEntity findByName(String name) {
+        return departmentRepository.findByName(name);
+    }
+
+    @Override
+    public List<String> findByNameLike(String name) {
+        return departmentRepository.findByNameLike(name);
+    }
+}

+ 133 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/backend/impl/ResourceServiceImpl.java

@@ -0,0 +1,133 @@
+package com.fdkankan.service.backend.impl;
+
+import com.fdkankan.dao.backend.IBaseRepository;
+import com.fdkankan.dao.backend.ResourceRepository;
+import com.fdkankan.dao.backend.RoleRepository;
+import com.fdkankan.dao.backend.UserRepository;
+import com.fdkankan.domain.backend.ResourceEntity;
+import com.fdkankan.domain.backend.UserEntity;
+import com.fdkankan.service.BaseServiceImpl;
+import com.fdkankan.service.backend.util.ResourceTreeUtil;
+import com.fdkankan.service.backend.ResourceService;
+import com.fdkankan.service.backend.dto.ResourceTree;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigInteger;
+import java.util.*;
+
+
+/**
+ * Created by owen on 2020/2/18 0018 11:37
+ */
+@Service
+@Transactional
+public class ResourceServiceImpl extends BaseServiceImpl<ResourceEntity, String> implements ResourceService {
+
+    @Autowired
+    private ResourceRepository resourceRepository;
+
+    @Autowired
+    private UserRepository userRepository;
+
+    @Autowired
+    private RoleRepository roleRepository;
+
+    @Override
+    public IBaseRepository<ResourceEntity, String> getBaseMapper() {
+        return this.resourceRepository;
+    }
+
+    /**
+     * 获取用户菜单
+     * @param userEntity
+     * @return
+     * @throws Exception
+     */
+    @Override
+    @Cacheable(value = "resourcesUserCache", key = "#root.caches[0].name + ':' + #user.id")
+    public List<ResourceTree> getResourcesTreeByUserMenu(UserEntity userEntity) throws Exception {
+        //Get userEntity menu
+
+        // 资源Mapper
+        HashMap<String, ResourceEntity> allResourceMapper = getAllResourceMapper();
+
+        // 获取用户菜单
+        List<ResourceEntity> resourcesUserMenu = new ArrayList<>();
+        Set<String> roleIds = userRepository.findUserRoleByUserId(userEntity.getId());
+        for (String i: roleIds) {
+
+            Set<String> resourceSet = roleRepository.findRoleResourceByRoleId(i);
+            for (String j : resourceSet ) {
+                ResourceEntity resourceEntity = allResourceMapper.get(j);
+                if ("menu".equals(resourceEntity.getResourceType())) {
+                    resourcesUserMenu.add(resourceEntity);
+                }
+            }
+        }
+        ResourceTreeUtil tree = new ResourceTreeUtil(resourcesUserMenu);
+        return tree.buildTree();
+    }
+
+    /**
+     * 获取用户权限树
+     * @param userEntity
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public List<ResourceTree> getResourcesTreeByUserPermission(UserEntity userEntity) throws Exception {
+        ResourceTreeUtil tree = new ResourceTreeUtil(getResourcesByUserPermission(userEntity));
+        return tree.buildTree();
+    }
+
+    @Override
+    @Cacheable(value = "resourcesCache")
+    public List<ResourceTree> getTree() throws Exception {
+        List<ResourceEntity> resourceEntities = resourceRepository.selectAll();
+        ResourceTreeUtil tree = new ResourceTreeUtil(resourceEntities);
+        return tree.buildTree();
+    }
+
+    /**
+     * 获取用户权限
+     * @param userEntity
+     * @return
+     */
+    @Override
+    public List<ResourceEntity> getResourcesByUserPermission(UserEntity userEntity) {
+        // 资源Mapper
+        HashMap<String, ResourceEntity> allResourceMapper = getAllResourceMapper();
+        // 获取用户菜单
+        List<ResourceEntity> resourcesUserPermission = new ArrayList<>();
+        Set<String> roleIds = userRepository.findUserRoleByUserId(userEntity.getId());
+        for (String i: roleIds) {
+            Set<String> resourceSet = roleRepository.findRoleResourceByRoleId(i);
+            for (String j : resourceSet ) {
+                ResourceEntity resourceEntity = allResourceMapper.get(j);
+                resourcesUserPermission.add(resourceEntity);
+            }
+        }
+        return resourcesUserPermission;
+    }
+
+
+    /**
+     * 获取资源映射作为缓存
+     * @return
+     */
+    private HashMap<String, ResourceEntity> getAllResourceMapper(){
+        // 查找所有resources
+        List<ResourceEntity> resourceEntityAll = resourceRepository.selectAll();
+        // 资源Mapper
+        HashMap<String, ResourceEntity> resourceMapper = new HashMap<>();
+        for (ResourceEntity i : resourceEntityAll) {
+            resourceMapper.put(i.getId(), i);
+        }
+        return resourceMapper;
+    }
+
+
+}

+ 53 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/backend/impl/RoleServiceImpl.java

@@ -0,0 +1,53 @@
+package com.fdkankan.service.backend.impl;
+
+import com.fdkankan.dao.backend.IBaseRepository;
+import com.fdkankan.dao.backend.RoleRepository;
+import com.fdkankan.domain.backend.RoleEntity;
+import com.fdkankan.service.BaseServiceImpl;
+import com.fdkankan.service.backend.RoleService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigInteger;
+import java.util.Set;
+
+
+/**
+ * Created by owen on 2020/2/18 0018 11:37
+ */
+@Service
+@Transactional
+public class RoleServiceImpl extends BaseServiceImpl<RoleEntity, String> implements RoleService {
+
+    @Autowired
+    private RoleRepository roleRepository;
+
+    @Override
+    public IBaseRepository<RoleEntity, String> getBaseMapper() {
+        return this.roleRepository;
+    }
+
+
+    @Override
+    public void saveRoleResource(String roleId, String resourceId) {
+        roleRepository.saveRoleResource(roleId, resourceId);
+    }
+
+    @Override
+    public void deleteRoleResource(String roleId) {
+        roleRepository.deleteRoleResource(roleId);
+    }
+
+    @Override
+    public Set<String> findRoleResourceByRoleId(String id) {
+        return roleRepository.findRoleResourceByRoleId(id);
+    }
+
+    @Override
+    public RoleEntity findByUserId(String id) {
+        return roleRepository.findByUserId(id);
+    }
+
+
+}

+ 26 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/backend/impl/UserRoleServiceImpl.java

@@ -0,0 +1,26 @@
+package com.fdkankan.service.backend.impl;
+
+import com.fdkankan.dao.backend.IBaseRepository;
+import com.fdkankan.dao.backend.UserRoleRepository;
+import com.fdkankan.domain.backend.UserRoleEntity;
+import com.fdkankan.service.BaseServiceImpl;
+import com.fdkankan.service.backend.UserRoleService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Created by Hb_zzZ on 2021/1/4.
+ */
+@Service
+@Transactional
+public class UserRoleServiceImpl extends BaseServiceImpl<UserRoleEntity, String> implements UserRoleService{
+
+    @Autowired
+    private UserRoleRepository userRoleRepository;
+
+    @Override
+    public IBaseRepository<UserRoleEntity, String> getBaseMapper() {
+        return userRoleRepository;
+    }
+}

+ 72 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/backend/impl/UserServiceImpl.java

@@ -0,0 +1,72 @@
+package com.fdkankan.service.backend.impl;
+
+import com.fdkankan.service.BaseServiceImpl;
+import com.fdkankan.service.backend.UserService;
+import com.github.pagehelper.PageHelper;
+import com.fdkankan.dao.backend.IBaseRepository;
+import com.fdkankan.dao.backend.UserRepository;
+import com.fdkankan.domain.backend.UserEntity;
+import com.fdkankan.domain.dto.request.UserRequest;
+import com.fdkankan.domain.dto.response.UserResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigInteger;
+import java.util.List;
+import java.util.Set;
+
+
+/**
+ * Created by owen on 2020/2/18 0018 11:37
+ */
+@Service
+@Transactional
+public class UserServiceImpl extends BaseServiceImpl<UserEntity, String> implements UserService {
+
+    @Autowired
+    private UserRepository userRepository;
+
+    @Override
+    public IBaseRepository<UserEntity, String> getBaseMapper() {
+        return this.userRepository;
+    }
+
+//    @Override
+//    public void saveUserRole(Long userId, Long roleId) {
+//        userRepository.saveUserRole(userId, roleId);
+//    }
+
+    @Override
+    public void deleteUserRole(String userId) {
+        userRepository.deleteUserRole(userId);
+    }
+
+    @Override
+    public UserEntity findByUserName(String userName) {
+        return userRepository.findByUserName(userName);
+    }
+
+    @Override
+    public Set<String> findUserRoleByUserId(String userId) {
+        return userRepository.findUserRoleByUserId(userId);
+    }
+
+    @Override
+    public List<String> findUserIdByRealName(String realName) {
+        return userRepository.findUserIdByRealName(realName);
+    }
+
+    @Override
+    public List<UserResponse> findAllBySearchKey(UserRequest param) {
+        PageHelper.startPage(param.getPageNum(), param.getPageSize());
+        return userRepository.findAllBySearchKey(param);
+    }
+
+    @Override
+    public String findRoleKey(String userId) {
+        return userRepository.findRoleKey(userId);
+    }
+
+
+}

+ 107 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/backend/util/DepartmentTreeUtil.java

@@ -0,0 +1,107 @@
+package com.fdkankan.service.backend.util;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.domain.backend.DepartmentEntity;
+import com.fdkankan.domain.backend.ResourceEntity;
+import com.fdkankan.service.backend.dto.DepartmentTree;
+import com.fdkankan.service.backend.dto.DepartmentTree;
+import com.github.pagehelper.util.StringUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DepartmentTreeUtil {
+
+    private List<DepartmentTree> resultNodes = new ArrayList<DepartmentTree>();//树形结构排序之后list内容
+
+    private List<DepartmentTree> nodes = new ArrayList<DepartmentTree>();
+    //传入list参数
+
+    public DepartmentTreeUtil(List<DepartmentEntity> nodesList) {//通过构造函数初始化
+        for (DepartmentEntity n : nodesList) {
+            DepartmentTree treeGrid = new DepartmentTree();
+            treeGrid.setId(n.getId());
+            treeGrid.setName(n.getName());
+//            treeGrid.setIcon(n.getIcon());
+            treeGrid.setNum(n.getNum());
+            if (n.getParentId() != null) {
+                treeGrid.setParentId(n.getParentId());
+            }
+            nodes.add(treeGrid);
+        }
+    }
+
+    public DepartmentTreeUtil() {
+    }
+
+    /**
+     * 构建树形结构list
+     *
+     * @return 返回树形结构List列表
+     */
+    public List<DepartmentTree> buildTree() {
+        for (DepartmentTree node : nodes) {
+            String id = node.getParentId();
+            if (StringUtil.isEmpty(id)) {//通过循环一级节点 就可以通过递归获取二级以下节点
+                resultNodes.add(node);//添加一级节点
+//                node.setLevel(1);
+                build(node, node.getLevel());//递归获取二级、三级、。。。节点
+            }
+        }
+        return resultNodes;
+    }
+
+    /**
+     * 递归循环子节点
+     *
+     * @param node 当前节点
+     */
+    private void build(DepartmentTree node, int level) {
+        List<DepartmentTree> children = getChildren(node);
+        if (!children.isEmpty()) {//如果存在子节点
+            node.setChildren(children);
+//        	level++;
+            for (DepartmentTree child : children) {//将子节点遍历加入返回值中
+//        		child.setLevel(level);
+                build(child, child.getLevel());
+            }
+        }
+    }
+
+    /**
+     * @param node
+     * @return 返回
+     */
+    private List<DepartmentTree> getChildren(DepartmentTree node) {
+        List<DepartmentTree> children = new ArrayList<DepartmentTree>();
+        String id = node.getId();
+        for (DepartmentTree child : nodes) {
+            if (id.equals(child.getParentId())) {//如果id等于父id
+                children.add(child);//将该节点加入循环列表中
+            }
+        }
+        return children;
+    }
+
+    public List<DepartmentTree> buildTree(List<ResourceEntity> all, List<ResourceEntity> in) {
+        for (ResourceEntity n : all) {
+            DepartmentTree treeGrid = new DepartmentTree();
+            treeGrid.setId(n.getId());
+            treeGrid.setName(n.getName());
+            for (ResourceEntity nin : in) {
+                if (nin.getId().equals(n.getId())) {
+                    treeGrid.setChecked(true);
+                }
+            }
+            if (n.getParentId() != null) {
+                treeGrid.setParentId(n.getParentId());
+            }
+            nodes.add(treeGrid);
+        }
+        return buildTree();
+    }
+
+
+}

+ 103 - 0
4dkankan-user-service/src/main/java/com/fdkankan/service/backend/util/ResourceTreeUtil.java

@@ -0,0 +1,103 @@
+package com.fdkankan.service.backend.util;
+
+import com.fdkankan.domain.backend.ResourceEntity;
+import com.fdkankan.service.backend.dto.ResourceTree;
+import com.github.pagehelper.util.StringUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ResourceTreeUtil {
+
+    private List<ResourceTree> resultNodes = new ArrayList<ResourceTree>();//树形结构排序之后list内容
+
+    private List<ResourceTree> nodes = new ArrayList<ResourceTree>();
+    //传入list参数
+
+    public ResourceTreeUtil(List<ResourceEntity> nodesList) {//通过构造函数初始化
+        for (ResourceEntity n : nodesList) {
+            ResourceTree treeGrid = new ResourceTree();
+            treeGrid.setId(n.getId());
+            treeGrid.setName(n.getName());
+//            treeGrid.setIcon(n.getIcon());
+            treeGrid.setUrl(n.getUrl());
+            treeGrid.setResourceKey(n.getResourceKey());
+            treeGrid.setResourceType(n.getResourceType());
+            if (n.getParentId() != null) {
+                treeGrid.setParentId(n.getParentId());
+            }
+            nodes.add(treeGrid);
+        }
+    }
+
+    public ResourceTreeUtil() {
+    }
+
+    /**
+     * 构建树形结构list
+     *
+     * @return 返回树形结构List列表
+     */
+    public List<ResourceTree> buildTree() {
+        for (ResourceTree node : nodes) {
+            String id = node.getParentId();
+            if (StringUtil.isEmpty(id)) {//通过循环一级节点 就可以通过递归获取二级以下节点
+                resultNodes.add(node);//添加一级节点
+//                node.setLevel(1);
+                build(node, node.getLevel());//递归获取二级、三级、。。。节点
+            }
+        }
+        return resultNodes;
+    }
+
+    /**
+     * 递归循环子节点
+     *
+     * @param node 当前节点
+     */
+    private void build(ResourceTree node, int level) {
+        List<ResourceTree> children = getChildren(node);
+        if (!children.isEmpty()) {//如果存在子节点
+            node.setChildren(children);
+//        	level++;
+            for (ResourceTree child : children) {//将子节点遍历加入返回值中
+//        		child.setLevel(level);
+                build(child, child.getLevel());
+            }
+        }
+    }
+
+    /**
+     * @param node
+     * @return 返回
+     */
+    private List<ResourceTree> getChildren(ResourceTree node) {
+        List<ResourceTree> children = new ArrayList<ResourceTree>();
+        String id = node.getId();
+        for (ResourceTree child : nodes) {
+            if (id.equals(child.getParentId())) {//如果id等于父id
+                children.add(child);//将该节点加入循环列表中
+            }
+        }
+        return children;
+    }
+
+    public List<ResourceTree> buildTree(List<ResourceEntity> all, List<ResourceEntity> in) {
+        for (ResourceEntity n : all) {
+            ResourceTree treeGrid = new ResourceTree();
+            treeGrid.setId(n.getId());
+            treeGrid.setName(n.getName());
+            for (ResourceEntity nin : in) {
+                if (nin.getId().equals(n.getId())) {
+                    treeGrid.setChecked(true);
+                }
+            }
+            if (n.getParentId() != null) {
+                treeGrid.setParentId(n.getParentId());
+            }
+            nodes.add(treeGrid);
+        }
+        return buildTree();
+    }
+
+}

+ 26 - 0
4dkankan-user-web/pom.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>fdkankan</artifactId>
+        <groupId>com.fdkankan</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>4dkankan-user-web</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0.0</version>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-user-service</artifactId>
+        </dependency>
+
+    </dependencies>
+
+
+</project>

+ 97 - 0
4dkankan-user-web/src/main/java/com/fdkankan/web/aop/CheckCurrenUserAspect.java

@@ -0,0 +1,97 @@
+package com.fdkankan.web.aop;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.common.constant.MsgCode;
+import com.fdkankan.common.exception.BaseRuntimeException;
+import com.github.pagehelper.util.StringUtil;
+import lombok.extern.log4j.Log4j2;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.annotation.Order;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.lang.reflect.Method;
+
+/**
+ * 权限控制,判断是否管理员操作权限
+ */
+@Log4j2
+@Aspect
+@Component
+@Order(2)
+public class CheckCurrenUserAspect {
+
+
+	@Autowired
+	private RedisTemplate<String, String> redisTemplate;
+
+
+	// Service层切点
+	@Pointcut("@annotation(com.fdkankan.web.aop.CheckCurrentUser)")
+	public void checkUserAspect() {
+	}
+
+	/**
+	 * 前置通知 用于拦截Controller层记录用户的操作
+	 *
+	 * @param joinPoint
+	 *            切点
+	 * @throws IOException
+	 */
+	@Before("checkUserAspect()")
+	public void doBefore(JoinPoint joinPoint) throws Exception {
+		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
+				.getRequest();
+		String token = request.getHeader("token");
+		if(StringUtil.isEmpty(token)){
+			throw new BaseRuntimeException(MsgCode.FAILURE_CODE_3004, MsgCode.FAILURE_MSG_3004);
+		}
+
+		String jsonStr = redisTemplate.opsForValue().get(token);
+		JSONObject user = null;
+		if (StringUtil.isNotEmpty(jsonStr)) {
+			user = JSONObject.parseObject(jsonStr);
+		}
+
+		if(user == null || !user.containsKey("roleKey") || (!"admin".equals(user.getString("roleKey")) &&
+				!"group".equals(user.getString("roleKey")))){
+			throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4010, MsgCode.FAILURE_MSG_4010);
+		}
+
+	}
+
+	/**
+	 * 获取注解中对方法的描述信息
+	 *
+	 * @param joinPoint
+	 *            切点
+	 * @return 方法描述
+	 * @throws Exception
+	 */
+	public static String getCheckUserMthodDescription(JoinPoint joinPoint) throws Exception {
+		String targetName = joinPoint.getTarget().getClass().getName();
+		String methodName = joinPoint.getSignature().getName();
+		Object[] arguments = joinPoint.getArgs();
+		Class targetClass = Class.forName(targetName);
+		Method[] methods = targetClass.getMethods();
+		String description = "";
+		for (Method method : methods) {
+			if (method.getName().equals(methodName)) {
+				Class[] clazzs = method.getParameterTypes();
+				if (clazzs.length == arguments.length) {
+					description = method.getAnnotation(CheckCurrentUser.class).description();
+					break;
+				}
+			}
+		}
+		return description;
+	}
+}

+ 10 - 0
4dkankan-user-web/src/main/java/com/fdkankan/web/aop/CheckCurrentUser.java

@@ -0,0 +1,10 @@
+package com.fdkankan.web.aop;
+
+import java.lang.annotation.*;
+
+@Target({ElementType.PARAMETER, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface CheckCurrentUser {
+    String description() default "";
+}

+ 13 - 0
4dkankan-user-web/src/main/java/com/fdkankan/web/aop/WebControllerLog.java

@@ -0,0 +1,13 @@
+package com.fdkankan.web.aop;
+
+import java.lang.annotation.*;
+
+/**
+ * Created by Hb_zzZ on 2020/2/27.
+ */
+@Target({ElementType.PARAMETER, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface WebControllerLog {
+    String description() default "";
+}

+ 149 - 0
4dkankan-user-web/src/main/java/com/fdkankan/web/aop/WebLogAspect.java

@@ -0,0 +1,149 @@
+package com.fdkankan.web.aop;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.domain.dto.request.OperationRequest;
+import com.fdkankan.service.backend.feign.OperatorFeign;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Enumeration;
+
+/**
+ * Created by owen on 2020/2/25 0025 9:24
+ */
+@Slf4j
+@Aspect
+@Component
+public class WebLogAspect {
+
+    @Autowired
+    private RedisTemplate<String, String> redisTemplate;
+
+    @Autowired
+    private OperatorFeign operatorFeign;
+
+    @Pointcut("@annotation(com.fdkankan.web.aop.WebControllerLog)")//切入点描述 这个是controller包的切入点
+    public void controllerLog(){}//签名,可以理解成这个切入点的一个名称
+
+    @Before("controllerLog()") //在切入点的方法run之前要干的
+    public void logBeforeController(JoinPoint joinPoint) throws Exception{
+
+        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
+                .getRequest();
+
+        String token = request.getHeader("token");
+        if(StringUtils.isEmpty(token)){
+            log.info("用户未登陆,记录日志失败!");
+            return;
+        }
+
+        // 读取redis中的用户信息
+        String redisToken = redisTemplate.opsForValue().get(token);
+        if(StringUtils.isEmpty(redisToken)){
+            log.info("用户未登陆,记录日志失败!");
+            return;
+        }
+
+
+        // 请求的IP
+        String ip = request.getRemoteAddr();
+        String params = "";
+        JSONObject jsonObject = new JSONObject();
+        try {
+            // *========控制台输出=========*//
+            JSONObject tokenJson = JSON.parseObject(redisToken);
+            String departmentName = tokenJson.getString("departmentName");
+            String nickName = tokenJson.getString("nickName");
+            String roleId = tokenJson.getString("roleId");
+            String departmentId = tokenJson.getString("departmentId");
+            String roleName = tokenJson.getString("roleName");
+            String id = tokenJson.getString("id");
+            String userName = tokenJson.getString("userName");
+
+            log.info("=====前置通知开始=====");
+            log.info("请求方法:"
+                    + (joinPoint.getTarget().getClass().getName() + "." + joinPoint.getSignature().getName() + "()"));
+            log.info("方法描述:" + getControllerLogDescription(joinPoint));
+            log.info("请求人:" + (userName == null ? "" : userName));
+            log.info("请求IP:" + ip);
+            for(Object obj : joinPoint.getArgs()){
+                if(obj instanceof HttpServletRequest){
+                    Enumeration enu = ((HttpServletRequest)obj).getParameterNames();
+                    while(enu.hasMoreElements()){
+                        String paraName=(String)enu.nextElement();
+                        jsonObject.put(paraName, request.getParameter(paraName));
+                        params = jsonObject.toString();
+                    }
+                }else {
+                    if("".equals(params)){
+                        params = obj.toString();
+                    }
+                }
+            }
+            log.info("请求内容:" + params);
+
+            String[] operationData = getControllerLogDescription(joinPoint).split("---");
+            OperationRequest param = new OperationRequest();
+            param.setOperateContent(operationData[1]);
+            param.setOperateTime(new Date());
+            param.setOperateType(operationData[0]);
+            param.setOperatorCompanyId(departmentId);
+            param.setOperatorCompanyName(departmentName);
+            param.setOperatorId(id);
+            param.setOperatorName(nickName);
+            param.setOperatorPhone(userName);
+            param.setOperatorRoleId(roleId);
+            param.setOperatorRoleName(roleName);
+            log.info("operatorFeign请求参数:" + JSONObject.toJSON(param));
+            operatorFeign.addNew(param, request.getHeader("token"));
+            log.info("=====前置通知结束=====");
+        } catch (Exception e) {
+            // 记录本地异常日志
+            log.error("==前置通知异常==");
+            log.error("异常信息:{}", e.getMessage());
+        }
+    }
+
+    /**
+     * 获取注解中对方法的描述信息 用于Controller层注解
+     *
+     * @param joinPoint
+     *            切点
+     * @return 方法描述
+     * @throws Exception
+     */
+    public static String getControllerLogDescription(JoinPoint joinPoint) throws Exception {
+        String targetName = joinPoint.getTarget().getClass().getName();
+        String methodName = joinPoint.getSignature().getName();
+        Object[] arguments = joinPoint.getArgs();
+        Class targetClass = Class.forName(targetName);
+        Method[] methods = targetClass.getMethods();
+        String description = "";
+        for (Method method : methods) {
+            if (method.getName().equals(methodName)) {
+                Class[] clazzs = method.getParameterTypes();
+                if (clazzs.length == arguments.length) {
+                    description = method.getAnnotation(WebControllerLog.class).description();
+                    break;
+                }
+            }
+        }
+        return description;
+    }
+}

+ 20 - 0
4dkankan-user-web/src/main/java/com/fdkankan/web/backend/BaseController.java

@@ -0,0 +1,20 @@
+package com.fdkankan.web.backend;
+
+import com.fdkankan.web.shiro.JWTUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Created by owen on 2020/2/20 0020 15:20
+ */
+public class BaseController {
+
+    @Autowired
+    protected HttpServletRequest request;
+
+    protected String getTokenUserName(){
+        String token = request.getHeader("token");
+        return JWTUtil.getUsername(token);
+    }
+}

+ 216 - 0
4dkankan-user-web/src/main/java/com/fdkankan/web/backend/DepartmentController.java

@@ -0,0 +1,216 @@
+package com.fdkankan.web.backend;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fdkankan.common.exception.BaseRuntimeException;
+import com.fdkankan.common.util.Result;
+import com.fdkankan.domain.backend.UserEntity;
+import com.fdkankan.domain.dto.response.ResponseCamera;
+import com.fdkankan.service.backend.UserService;
+import com.fdkankan.service.backend.feign.CameraFeign;
+import com.fdkankan.service.backend.util.DepartmentTreeUtil;
+import com.fdkankan.common.constant.MsgCode;
+import com.fdkankan.domain.backend.DepartmentEntity;
+import com.fdkankan.domain.dto.request.DepartmentRequest;
+import com.fdkankan.service.backend.DepartmentService;
+import com.fdkankan.web.aop.CheckCurrentUser;
+import com.fdkankan.web.aop.WebControllerLog;
+import com.github.pagehelper.util.StringUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import tk.mybatis.mapper.entity.Condition;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by Hb_zzZ on 2020/2/27.
+ */
+@Api(tags = "后台部门管理", description = "后台部门管理")
+@RestController
+@RequestMapping("api/manage/department")
+@Transactional
+public class DepartmentController {
+
+    @Autowired
+    private DepartmentService departmentService;
+
+    @Autowired
+    private UserService userService;
+
+    @Autowired
+    private CameraFeign cameraFeign;
+
+    @Autowired
+    private RedisTemplate<String, String> redisTemplate;
+
+    @ApiOperation("获取部门列表")
+    @PostMapping("list")
+    public Result list(HttpServletRequest request) throws Exception{
+        String redisToken = redisTemplate.opsForValue().get(request.getHeader("token"));
+        if(StringUtils.isNotEmpty(redisToken)){
+            JSONObject tokenJson = JSON.parseObject(redisToken);
+            if("region".equals(tokenJson.getString("roleKey"))){
+                List<DepartmentEntity> list = new ArrayList<>();
+                list.add(departmentService.findById(tokenJson.getString("departmentId")));
+                return Result.success(list);
+            }
+        }
+
+        List<DepartmentEntity> list = departmentService.findAll();
+        return Result.success(list);
+    }
+
+    @ApiOperation("获取部门列表树")
+    @PostMapping("listTree")
+//    @WebControllerLog(description = "组织架构---查询组织架构")
+    public Result listTree() throws Exception{
+        List<DepartmentEntity> list = departmentService.findAll();
+        return Result.success(new DepartmentTreeUtil(list).buildTree());
+    }
+
+    @ApiOperation("新增部门")
+    @WebControllerLog(description = "组织架构---新增组织架构")
+    @PostMapping("save")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "name", value = "组织名称", dataType = "String", required = true),
+            @ApiImplicitParam(name = "num", value = "编码", dataType = "String"),
+            @ApiImplicitParam(name = "parentId", value = "parentId(上级组织id)", dataType = "String")})
+    @CheckCurrentUser()
+    public Result save(@RequestBody DepartmentRequest param) throws Exception{
+        if(StringUtils.isEmpty(param.getName()) ){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_3001, MsgCode.FAILURE_MSG_3001);
+        }
+
+        DepartmentEntity departmentEntity = departmentService.findByName(param.getName());
+        if(departmentEntity != null){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_5001, MsgCode.FAILURE_MSG_5001);
+        }
+        if(param.getParentId() != null){
+            departmentEntity = departmentService.findById(param.getParentId());
+            if(departmentEntity == null){
+                throw new BaseRuntimeException(MsgCode.FAILURE_CODE_5004, MsgCode.FAILURE_MSG_5004);
+            }
+
+            if(StringUtil.isNotEmpty(departmentEntity.getParentId())){
+                throw new BaseRuntimeException(MsgCode.FAILURE_CODE_5005, MsgCode.FAILURE_MSG_5005);
+            }
+        }
+
+        departmentEntity = new DepartmentEntity();
+        BeanUtils.copyProperties(param, departmentEntity);
+        departmentService.save(departmentEntity);
+        return Result.success(departmentEntity);
+    }
+
+    @ApiOperation("修改")
+    @WebControllerLog(description = "组织架构---修改组织架构")
+    @PostMapping("update")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "String"),
+            @ApiImplicitParam(name = "name", value = "组织名称", dataType = "String", required = true)})
+    @CheckCurrentUser()
+    public Result update(@RequestBody DepartmentRequest param) throws Exception{
+        if(StringUtils.isEmpty(param.getId()) || StringUtils.isEmpty(param.getName()) ){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_3001, MsgCode.FAILURE_MSG_3001);
+        }
+
+        DepartmentEntity departmentEntity = departmentService.findByName(param.getName());
+        if(departmentEntity != null && !departmentEntity.getId().equals(param.getId()) ){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_5001, MsgCode.FAILURE_MSG_5001);
+        }
+
+        departmentEntity = new DepartmentEntity();
+        departmentEntity.setId(param.getId());
+        departmentEntity.setName(param.getName());
+        departmentService.update(departmentEntity);
+        return Result.success(departmentEntity);
+    }
+
+    @ApiOperation("删除部门")
+    @PostMapping("delete")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "String")})
+    @WebControllerLog(description = "组织架构---删除组织架构")
+    @CheckCurrentUser()
+    public Result delete(@RequestBody DepartmentRequest param, HttpServletRequest request){
+        if(param.getId() == null){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_3001, MsgCode.FAILURE_MSG_3001);
+        }
+
+        Condition condition = new Condition(UserEntity.class);
+        condition.and().andEqualTo("departmentId", param.getId());
+        List<UserEntity> list = userService.findAll(condition);
+        if(list != null && list.size() > 0){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_5003, MsgCode.FAILURE_MSG_5003);
+        }
+
+        DepartmentRequest findParam = new DepartmentRequest();
+        findParam.setDepartmentId(param.getId());
+        Result result = cameraFeign.findByDepartmentId(findParam, request.getHeader("token"));
+
+        if(result.getCode() == 0){
+            ObjectMapper objectMapper = new ObjectMapper();
+
+            ResponseCamera responseCamera = objectMapper.convertValue(result.getData(), ResponseCamera.class);
+            if(responseCamera != null){
+                throw new BaseRuntimeException(MsgCode.FAILURE_CODE_5003, MsgCode.FAILURE_MSG_5003);
+            }
+        }
+
+        departmentService.deleteById(param.getId());
+        return Result.success();
+    }
+
+    @ApiOperation("根据id查询详情")
+    @PostMapping("findById")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "String")})
+    public Result findById(@RequestBody DepartmentRequest param){
+        if(param.getId() == null){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_3001, MsgCode.FAILURE_MSG_3001);
+        }
+
+        return Result.success(departmentService.findById(param.getId()));
+    }
+
+    @ApiOperation("根据名称模糊查询")
+    @PostMapping("findByNameLike")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "name", value = "组织名称", dataType = "String")})
+    public Result findByNameLike(@RequestBody DepartmentRequest param){
+        if(StringUtils.isEmpty(param.getName())){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_3001, MsgCode.FAILURE_MSG_3001);
+        }
+
+        return Result.success(departmentService.findByNameLike(param.getName()));
+    }
+
+    @ApiOperation("根据id查询所有子部门")
+    @PostMapping("findChildrenById")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "String")})
+    public Result findChildrenById(@RequestBody DepartmentRequest param){
+        if(param.getId() == null){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_3001, MsgCode.FAILURE_MSG_3001);
+        }
+
+        Condition condition = new Condition(DepartmentEntity.class);
+        condition.and().andEqualTo("parentId", param.getId());
+
+        return Result.success(departmentService.findAll(condition));
+    }
+}

+ 281 - 0
4dkankan-user-web/src/main/java/com/fdkankan/web/backend/IndexController.java

@@ -0,0 +1,281 @@
+package com.fdkankan.web.backend;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.common.constant.MsgCode;
+import com.fdkankan.common.exception.BaseRuntimeException;
+import com.fdkankan.common.util.*;
+import com.fdkankan.domain.backend.DepartmentEntity;
+import com.fdkankan.domain.backend.RoleEntity;
+import com.fdkankan.domain.backend.UserEntity;
+import com.fdkankan.domain.dto.request.OperationRequest;
+import com.fdkankan.domain.dto.request.UserRequest;
+import com.fdkankan.service.backend.DepartmentService;
+import com.fdkankan.service.backend.ResourceService;
+import com.fdkankan.service.backend.RoleService;
+import com.fdkankan.service.backend.UserService;
+import com.fdkankan.service.backend.dto.ResourceTree;
+import com.fdkankan.service.backend.feign.OperatorFeign;
+import com.fdkankan.web.aop.WebControllerLog;
+import com.fdkankan.web.shiro.JWTUtil;
+import com.github.pagehelper.util.StringUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Created by owen on 2020/2/19 0019 15:53
+ */
+@Api(tags = "后台登录管理", description = "后台登录管理")
+@RestController
+@RequestMapping("api/manage/user")
+@Transactional
+@Log4j2
+public class IndexController {
+
+    @Autowired
+    private UserService userService;
+
+    @Autowired
+    private ResourceService resourceService;
+
+    @Autowired
+    private DepartmentService departmentService;
+
+    @Autowired
+    private RoleService roleService;
+
+    @Autowired
+    private RedisTemplate<String, String> redisTemplate;
+
+    @Autowired
+    private OperatorFeign operatorFeign;
+
+
+    @ApiOperation("用户登陆")
+    @PostMapping(value = "/login")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "key", value = "随机关键字", dataType = "String", required = true),
+            @ApiImplicitParam(name = "code", value = "验证码", dataType = "String", required = true),
+            @ApiImplicitParam(name = "userName", value = "用户名", dataType = "String", required = true),
+            @ApiImplicitParam(name = "password", value = "密码", dataType = "String", required = true)})
+    public Result login(@RequestBody UserRequest param) throws Exception {
+        log.warn("run login , userName:{}, password:{}", param.getUserName(), param.getPassword());
+
+        //校验验证码
+        String random = redisTemplate.opsForValue().get("validateCode#" + param.getKey());
+        log.info("random:" + random);
+        if (random == null) {
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4008, MsgCode.FAILURE_MSG_4008);
+        }
+        if (!random.equals(param.getCode())) {
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4008, MsgCode.FAILURE_MSG_4008);
+        }
+        redisTemplate.delete("validateCode#" + param.getKey());
+
+        //校验错误次数
+        String numStr = redisTemplate.opsForValue().get("loginError#" + param.getUserName());
+        int num = 0;
+        if(StringUtil.isNotEmpty(numStr)){
+            num = Integer.parseInt(numStr);
+        }
+
+        if(num >= 5){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4009, MsgCode.FAILURE_MSG_4009);
+        }
+
+        // 1.获取用户
+        UserEntity userEntity = userService.findByUserName(param.getUserName());
+        if (userEntity == null) {
+            num = num + 1;
+            if(num == 5){
+                redisTemplate.opsForValue().set("loginError#" + param.getUserName(), String.valueOf(num), 5, TimeUnit.MINUTES);
+            }else {
+                redisTemplate.opsForValue().set("loginError#" + param.getUserName(), String.valueOf(num), 1, TimeUnit.MINUTES);
+            }
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4001, MsgCode.FAILURE_MSG_4001);
+        }
+
+        //对前端传的密码解密
+        if (param.getPassword().length() < 25) {
+            num = num + 1;
+            if(num == 5){
+                redisTemplate.opsForValue().set("loginError#" + param.getUserName(), String.valueOf(num), 5, TimeUnit.MINUTES);
+            }else {
+                redisTemplate.opsForValue().set("loginError#" + param.getUserName(), String.valueOf(num), 1, TimeUnit.MINUTES);
+            }
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4001, MsgCode.FAILURE_MSG_4001);
+        }
+        String password = Base64Converter.decode(Base64Converter.subText(param.getPassword()));
+        param.setPassword(password);
+
+        // 验证密码
+        String encrypt = PasswordUtils.encrypt(userEntity.getUserName(), param.getPassword(), PasswordUtils.getStaticSalt());
+        if (!userEntity.getPassword().equals(encrypt)) {
+            num = num + 1;
+            if(num == 5){
+                redisTemplate.opsForValue().set("loginError#" + param.getUserName(), String.valueOf(num), 5, TimeUnit.MINUTES);
+            }else {
+                redisTemplate.opsForValue().set("loginError#" + param.getUserName(), String.valueOf(num), 1, TimeUnit.MINUTES);
+            }
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4001, MsgCode.FAILURE_MSG_4001);
+        }
+
+        // 检查账号是否启用
+        if (userEntity.getStatus() != 0) {
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4003, MsgCode.FAILURE_MSG_4003);
+        }
+
+        // 获取用户菜单
+        List<ResourceTree> resourcesByUserMenu = resourceService.getResourcesTreeByUserMenu(userEntity);
+
+        List<ResourceTree> resourcesTreeByUserPermission = resourceService.getResourcesTreeByUserPermission(userEntity);
+
+        // 创建新token
+        String token = JWTUtil.sign(param.getUserName(), userEntity.getPassword());
+        log.warn("new token: {}", token);
+
+        String roleKey = userService.findRoleKey(userEntity.getId());
+        JSONObject json = new JSONObject();
+        json.put("id", userEntity.getId());
+        json.put("nickName", userEntity.getNickName());
+        json.put("userName", userEntity.getUserName());
+        json.put("departmentId", userEntity.getDepartmentId());
+        DepartmentEntity department = departmentService.findById(userEntity.getDepartmentId());
+        if (department != null) {
+            json.put("departmentName", department.getName());
+        }
+        RoleEntity roleEntity = roleService.findByUserId(userEntity.getId());
+        if (roleEntity != null) {
+            json.put("roleId", roleEntity.getId());
+            json.put("roleName", roleEntity.getRoleName());
+        }
+        json.put("userName", userEntity.getUserName());
+        json.put("roleKey", roleKey);
+        json.put("resourcesTreeByUserPermission", resourcesTreeByUserPermission);
+        // 更新到 redis, 有效期24h, 旧token无效
+        redisTemplate.opsForValue().set(token, json.toJSONString(), Long.parseLong("24"), TimeUnit.HOURS);
+        log.info("token对应的值:" + json.toJSONString());
+
+
+        //记录登陆日志
+        OperationRequest operationData = new OperationRequest();
+        operationData.setOperateContent("用户登入");
+        operationData.setOperateTime(new Date());
+        operationData.setOperateType("用户管理");
+        operationData.setOperatorCompanyId(userEntity.getDepartmentId());
+        operationData.setOperatorCompanyName(department != null ? department.getName() : "");
+        operationData.setOperatorId(userEntity.getId());
+        operationData.setOperatorName(userEntity.getNickName());
+        operationData.setOperatorPhone(userEntity.getUserName());
+        operationData.setOperatorRoleId(roleEntity != null ? roleEntity.getId() : "");
+        operationData.setOperatorRoleName(roleEntity != null ? roleEntity.getRoleName() : "");
+        log.info("operatorFeign请求参数:" + JSONObject.toJSON(operationData));
+        operatorFeign.addNew(operationData, token);
+
+
+        HashMap<String, Object> result = new HashMap<>();
+        userEntity.setUserName(userEntity.getUserName().replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2"));
+        result.put("userEntity", userEntity);
+//        result.put("resources", resourcesByUserMenu);
+        result.put("token", token);
+        result.put("resourcesTreeByUserPermission", resourcesTreeByUserPermission);
+        return Result.success(result);
+    }
+
+    @ApiOperation("用户登出")
+    @GetMapping("/logout")
+    @WebControllerLog(description = "用户管理---用户登出")
+    public Result logout(HttpServletRequest request) {
+        log.info("run logout");
+
+        String token = request.getHeader("token");
+
+        String redisToken = (String) redisTemplate.opsForValue().get(token);
+        // token username 一致,代表没有被踢出
+        if (redisToken != null) {
+            redisTemplate.delete(token);
+        }
+
+        log.info("end logout");
+        return Result.success();
+    }
+
+    @ApiOperation("校验token")
+    @GetMapping("/checkToken")
+    public Result checkToken(HttpServletRequest request) {
+        log.info("run logout");
+
+        String token = request.getHeader("token");
+
+        String redisToken = redisTemplate.opsForValue().get(token);
+        // token username 一致,代表没有被踢出
+        if (redisToken == null) {
+            log.info(token + ":token失效");
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_3002, MsgCode.FAILURE_MSG_3002);
+        }
+
+        JSONObject tokenJson = JSON.parseObject(redisToken);
+        String id = tokenJson.getString("id");
+        UserEntity userEntity = userService.findById(id);
+        HashMap<String, Object> result = new HashMap<>();
+        result.put("userEntity", userEntity);
+
+        return Result.success(result);
+    }
+
+    /**
+     * 生成验证码
+     */
+    @ApiOperation("生成验证码")
+    @GetMapping(value = "/getVerify")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "key", value = "随机关键字", dataType = "String", required = true)})
+    public void getVerify(HttpServletRequest request, HttpServletResponse response) {
+        try {
+            response.setContentType("image/jpeg");//设置相应类型,告诉浏览器输出的内容为图片
+            response.setHeader("Pragma", "No-cache");//设置响应头信息,告诉浏览器不要缓存此内容
+            response.setHeader("Cache-Control", "no-cache");
+            response.setDateHeader("Expire", 0);
+            RandomValidateCodeUtil randomValidateCode = new RandomValidateCodeUtil();
+            randomValidateCode.getRandcode(request, response, redisTemplate);//输出验证码图片方法
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    @ApiOperation("校验验证码")
+    @GetMapping(value = "/checkVerify")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "key", value = "随机关键字", dataType = "String", required = true),
+            @ApiImplicitParam(name = "code", value = "验证码", dataType = "String", required = true)})
+    public Result checkVerify(String code, HttpServletRequest request) throws Exception {
+        //从session中获取随机数
+        String key = request.getParameter("key");
+        String random = redisTemplate.opsForValue().get("validateCode#" + key);
+        log.info("random:" + random);
+        if (random == null) {
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4008, MsgCode.FAILURE_MSG_4008);
+        }
+        if (!random.equals(code)) {
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4008, MsgCode.FAILURE_MSG_4008);
+        }
+        redisTemplate.delete("validateCode#" + key);
+        return Result.success();
+
+    }
+}

+ 101 - 0
4dkankan-user-web/src/main/java/com/fdkankan/web/backend/ResourceController.java

@@ -0,0 +1,101 @@
+package com.fdkankan.web.backend;
+
+import com.fdkankan.common.util.Result;
+import com.github.pagehelper.PageInfo;
+import com.fdkankan.common.constant.MsgCode;
+import com.fdkankan.common.model.PageDto;
+import com.fdkankan.common.util.ResultJson;
+import com.fdkankan.domain.backend.ResourceEntity;
+import com.fdkankan.domain.dto.request.ResourceRequest;
+import com.fdkankan.service.backend.ResourceService;
+import com.fdkankan.service.backend.dto.ResourceTree;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * Created by owen on 2020/2/18 0018 12:17
+ *
+ * 这一块的数据添加应该给开发者用,而不是给管理人员用
+ */
+@Api(tags = "后台资源管理", description = "后台资源管理")
+@RestController
+@RequestMapping("api/manage/resource")
+//@RequiresRoles("admin") //需要admin角色才可以访问此controller
+public class ResourceController {
+
+    @Autowired
+    private ResourceService resourceService;
+
+    @ApiOperation("分页获取资源列表")
+    @PostMapping("list")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "String", required = true),
+            @ApiImplicitParam(name = "pageSize", value = "页数", dataType = "String", required = true)})
+    public Result list(@RequestBody PageDto param) throws Exception{
+        PageInfo<ResourceEntity> pageInfo = resourceService.findAll(param.getPageNum(), param.getPageSize());
+        return Result.success(pageInfo);
+    }
+
+    @ApiOperation("获取资源")
+    @PostMapping("find")
+    public Result find() throws Exception {
+//        List<ResourceEntity> result = resourceService.findList(Sort.by("sort").ascending());
+        List<ResourceTree> listTree = resourceService.getTree();
+        return Result.success(listTree);
+    }
+
+    @ApiOperation("新增或修改资源信息")
+    @PostMapping("save")
+
+    public Result save(@RequestBody ResourceRequest param) throws Exception{
+        String id = param.getId();
+        ResourceEntity resourceEntity = null;
+
+        if (id != null) {
+            resourceEntity = resourceService.findById(id);
+        }
+
+        if (resourceEntity == null){
+            resourceEntity = new ResourceEntity();
+        }
+        BeanUtils.copyProperties(param, resourceEntity);
+
+//        resourceEntity.setCreateBy("updateUser");
+        resourceEntity.setUpdateTime(new Date());
+
+        resourceService.save(resourceEntity);
+
+        return Result.success();
+    }
+
+    @ApiOperation("查询资源信息")
+    @GetMapping("detail/{id}")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "String", required = true)})
+    public Result detail(@PathVariable String id){
+        ResourceEntity resourceEntity = resourceService.findById(id);
+        return Result.success(resourceEntity);
+    }
+
+    @ApiOperation("删除资源")
+    @GetMapping("delete/{id}")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "String", required = true)})
+    public Result delete(@PathVariable String id){
+        resourceService.deleteById(id);
+        return Result.success();
+    }
+
+
+
+
+}

+ 123 - 0
4dkankan-user-web/src/main/java/com/fdkankan/web/backend/RoleController.java

@@ -0,0 +1,123 @@
+package com.fdkankan.web.backend;
+
+import com.fdkankan.common.exception.BaseRuntimeException;
+import com.fdkankan.common.util.Result;
+import com.github.pagehelper.PageInfo;
+import com.fdkankan.common.constant.MsgCode;
+import com.fdkankan.common.util.ResultJson;
+import com.fdkankan.domain.backend.RoleEntity;
+import com.fdkankan.domain.dto.request.RoleRequest;
+import com.fdkankan.service.backend.RoleService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
+import tk.mybatis.mapper.entity.Condition;
+
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * Created by owen on 2020/2/18 0018 12:17
+ */
+@Api(tags = "后台角色管理", description = "后台角色管理")
+@RestController
+@RequestMapping("api/manage/role")
+@Transactional
+//@RequiresRoles("admin") //需要admin角色才可以访问此controller
+public class RoleController extends BaseController {
+
+    @Autowired
+    private RoleService roleService;
+
+    @ApiOperation("分页获取角色列表")
+    @PostMapping("list")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "String", required = true),
+            @ApiImplicitParam(name = "pageSize", value = "页数", dataType = "String", required = true)})
+    public Result list(@RequestBody RoleRequest param){
+        PageInfo<RoleEntity> pageInfo = roleService.findAll(param.getPageNum(), param.getPageSize());
+        return Result.success(pageInfo);
+    }
+
+//    @RequiresRoles("admin")
+    @ApiOperation("获取角色")
+    @GetMapping("find")
+    public Result find(){
+        Condition condition = new Condition(RoleEntity.class);
+        condition.and().andNotEqualTo("roleKey", "admin");
+        List<RoleEntity> result = roleService.findAll(condition, "sort desc");
+        return Result.success(result);
+    }
+
+    @ApiOperation("新增或修改角色信息")
+    @PostMapping("save")
+    public Result save(@RequestBody RoleRequest param) throws Exception{
+        RoleEntity roleEntity = null;
+        int n = 0;
+        if (param.getId() != null) {
+            roleEntity = roleService.findById(param.getId());
+            if(roleEntity == null){
+                throw new BaseRuntimeException(MsgCode.FAILURE_CODE_6001, MsgCode.FAILURE_MSG_6001);
+            }
+            // 每次修改,删除角色资源表信息,重新添加
+            roleService.deleteRoleResource(param.getId());
+
+            BeanUtils.copyProperties(param, roleEntity);
+            n = roleService.update(roleEntity);
+        }else {
+            roleEntity = new RoleEntity();
+
+            BeanUtils.copyProperties(param, roleEntity);
+            roleEntity.setUpdateTime(new Date());
+
+//        roleEntity.setCreateBy(getTokenUserName());
+
+            n = roleService.save(roleEntity);
+        }
+
+        if (n >= 0){
+            if (param.getResources() != null){
+                for (String i : param.getResources()) {
+                    roleService.saveRoleResource(roleEntity.getId(), i);
+                }
+                return Result.success();
+            }
+        }
+
+        return Result.success();
+    }
+
+    //测试权限
+
+    @ApiOperation("查询角色信息")
+    @GetMapping("detail/{id}")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "String", required = true)})
+    public Result detail(@PathVariable String id){
+        RoleEntity roleEntity = roleService.findById(id);
+        return Result.success(roleEntity);
+    }
+
+    @ApiOperation("删除角色")
+    @GetMapping("delete/{id}")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "String", required = true)})
+    public Result delete(@PathVariable String id){
+        roleService.deleteById(id);
+//        roleService.deleteRoleResource(id);
+        return Result.success();
+    }
+
+
+
+
+}

+ 285 - 0
4dkankan-user-web/src/main/java/com/fdkankan/web/backend/UserController.java

@@ -0,0 +1,285 @@
+package com.fdkankan.web.backend;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.common.exception.BaseRuntimeException;
+import com.fdkankan.common.util.*;
+import com.fdkankan.domain.backend.UserRoleEntity;
+import com.fdkankan.service.backend.UserRoleService;
+import com.fdkankan.web.aop.CheckCurrentUser;
+import com.fdkankan.web.aop.WebControllerLog;
+import com.github.pagehelper.PageInfo;
+import com.fdkankan.common.constant.MsgCode;
+import com.fdkankan.domain.dto.request.UserRequest;
+import com.fdkankan.domain.backend.UserEntity;
+import com.fdkankan.domain.dto.response.UserResponse;
+import com.fdkankan.service.backend.UserService;
+import com.github.pagehelper.util.StringUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+
+/**
+ * Created by owen on 2020/2/18 0018 12:17
+ */
+@Api(tags = "后台用户管理", description = "后台用户管理")
+@RestController
+@RequestMapping("api/manage/user")
+@Transactional
+public class UserController extends BaseController {
+
+    @Autowired
+    private UserService userService;
+
+    @Autowired
+    private UserRoleService userRoleService;
+
+    @Autowired
+    private RedisTemplate<String, String> redisTemplate;
+
+    @ApiOperation("分页获取用户列表")
+    @PostMapping("list")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "String", required = true),
+            @ApiImplicitParam(name = "pageSize", value = "页数", dataType = "String", required = true)})
+//    @WebControllerLog(description = "用户管理---获取用户列表")
+    @CheckCurrentUser()
+    public Result list(@RequestBody UserRequest param){
+        PageInfo<UserResponse> page =  new PageInfo<UserResponse>(userService.findAllBySearchKey(param));
+        return Result.success(page);
+    }
+
+    @ApiOperation("新增用户信息")
+    @PostMapping("save")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "userName", value = "手机号", dataType = "String", required = true),
+            @ApiImplicitParam(name = "password", value = "密码", dataType = "String", required = true),
+            @ApiImplicitParam(name = "confirmPwd", value = "确认密码", dataType = "String", required = true),
+            @ApiImplicitParam(name = "nickName", value = "姓名", dataType = "String", required = true),
+            @ApiImplicitParam(name = "departmentId", value = "所属架构id", dataType = "String", required = true),
+            @ApiImplicitParam(name = "roleId", value = "角色id", dataType = "String", required = true)})
+    @WebControllerLog(description = "用户管理---新增用户")
+    @CheckCurrentUser()
+    public Result save(@RequestBody UserRequest param, HttpServletRequest req) throws Exception{
+
+        UserEntity userEntity = null;
+        if (param.getRoleId() == null || param.getDepartmentId() == null || StringUtil.isEmpty(param.getPassword()) ||
+                StringUtil.isEmpty(param.getUserName()) || StringUtil.isEmpty(param.getConfirmPwd()) ||
+                StringUtil.isEmpty(param.getNickName())) {
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_3001, MsgCode.FAILURE_MSG_3001);
+        }
+        if(!param.getPassword().equals(param.getConfirmPwd())){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4004, MsgCode.FAILURE_MSG_4004);
+        }
+
+        //对前端传的密码解密
+        if(param.getPassword().length() < 25){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4001, MsgCode.FAILURE_MSG_4001);
+        }
+        String password = Base64Converter.decode(Base64Converter.subText(param.getPassword()));
+        param.setPassword(password);
+
+        if(!RegexUtils.validatePassword(param.getPassword())){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4007, MsgCode.FAILURE_MSG_4007);
+        }
+
+        if(!RegexUtils.validateMobilePhone(param.getUserName())){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4005, MsgCode.FAILURE_MSG_4005);
+        }
+
+        int n = 0;
+        userEntity = userService.findByUserName(param.getUserName());
+        if(userEntity != null){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4006, MsgCode.FAILURE_MSG_4006);
+        }
+
+
+        userEntity = new UserEntity();
+
+        BeanUtils.copyProperties(param, userEntity);
+        userEntity.setPassword(PasswordUtils.encrypt(param.getUserName(), param.getPassword(), PasswordUtils.getStaticSalt()));
+
+//           userEntity.setCreateBy(getTokenUserName());
+
+        n = userService.save(userEntity);
+
+
+        if (n >= 0) {
+            UserRoleEntity userRoleEntity = new UserRoleEntity();
+            userRoleEntity.setUserId(userEntity.getId());
+            userRoleEntity.setRoleId(param.getRoleId());
+            userRoleService.save(userRoleEntity);
+//                userService.saveUserRole(userEntity.getId(), param.getRoleId());
+            return Result.success();
+        }
+        return Result.success();
+    }
+
+    @ApiOperation("修改用户信息")
+    @PostMapping("update")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "用户id", dataType = "String", required = true),
+            @ApiImplicitParam(name = "nickName", value = "姓名", dataType = "String", required = true),
+            @ApiImplicitParam(name = "userName", value = "手机号", dataType = "String", required = true),
+            @ApiImplicitParam(name = "departmentId", value = "所属架构id", dataType = "String", required = true),
+            @ApiImplicitParam(name = "roleId", value = "角色id", dataType = "String", required = true)})
+    @WebControllerLog(description = "用户管理---修改用户")
+    @CheckCurrentUser()
+    public Result update(@RequestBody UserRequest param, HttpServletRequest req) throws Exception{
+
+        UserEntity userEntity = null;
+        if (StringUtil.isEmpty(param.getRoleId()) || StringUtil.isEmpty(param.getDepartmentId()) ||
+                StringUtil.isEmpty(param.getId()) || StringUtil.isEmpty(param.getNickName()) ) {
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_3001, MsgCode.FAILURE_MSG_3001);
+        }
+
+        if(StringUtil.isNotEmpty(param.getUserName())){
+            if(!RegexUtils.validateMobilePhone(param.getUserName())){
+                throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4005, MsgCode.FAILURE_MSG_4005);
+            }
+
+            userEntity = userService.findByUserName(param.getUserName());
+            if(userEntity != null && !userEntity.getId().equals(param.getId())){
+                throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4006, MsgCode.FAILURE_MSG_4006);
+            }
+        }
+
+        int n = 0;
+        userEntity = userService.findById(param.getId());
+        if(userEntity == null){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4001, MsgCode.FAILURE_MSG_4001);
+        }
+        // 每次修改,删除用户角色表信息,重新添加
+        userService.deleteUserRole(param.getId());
+
+        BeanUtils.copyProperties(param, userEntity);
+        userService.update(userEntity);
+
+
+        if (n >= 0) {
+            UserRoleEntity userRoleEntity = new UserRoleEntity();
+            userRoleEntity.setUserId(userEntity.getId());
+            userRoleEntity.setRoleId(param.getRoleId());
+            userRoleService.save(userRoleEntity);
+//                userService.saveUserRole(userEntity.getId(), param.getRoleId());
+            return Result.success();
+        }
+        return Result.success();
+    }
+
+    @ApiOperation("删除用户")
+    @GetMapping("delete/{id}")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "String", required = true)})
+    @WebControllerLog(description = "用户管理---删除用户")
+    @CheckCurrentUser()
+    public Result delete(@PathVariable String id){
+
+        userService.deleteById(id);
+//        userService.deleteUserRole(id);
+        return Result.success();
+    }
+
+    @ApiOperation("查询用户信息")
+    @GetMapping("detail/{id}")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "String", required = true)})
+    public Result detail(@PathVariable String id){
+        String token = request.getHeader("token");
+        if(StringUtil.isEmpty(token)){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_3004, MsgCode.FAILURE_MSG_3004);
+        }
+
+        String jsonStr = redisTemplate.opsForValue().get(token);
+        JSONObject user = null;
+        if (StringUtil.isNotEmpty(jsonStr)) {
+            user = JSONObject.parseObject(jsonStr);
+        }
+
+        if(user == null){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_3004, MsgCode.FAILURE_MSG_3004);
+        }
+
+        UserEntity userEntity = userService.findById(id);
+
+        if(userEntity == null){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4011, MsgCode.FAILURE_MSG_4011);
+        }
+
+        //判断用户是否有权限查看用户信息
+        if(!user.containsKey("roleKey") || !"admin".equals(user.getString("roleKey"))){
+            if(!id.equals(user.getString("id"))){
+                throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4010, MsgCode.FAILURE_MSG_4010);
+            }
+        }
+
+
+        return Result.success(userEntity);
+    }
+
+    @ApiOperation("修改密码")
+    @PostMapping("updatePwd")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "password", value = "新密码", dataType = "String", required = true),
+            @ApiImplicitParam(name = "oldPassword", value = "旧密码", dataType = "String", required = true)})
+    @WebControllerLog(description = "用户管理---修改密码")
+    public Result updatePwd(@RequestBody UserRequest param) throws Exception{
+
+        if(StringUtil.isEmpty(getTokenUserName())){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_3004, MsgCode.FAILURE_MSG_3004);
+        }
+        UserEntity userEntity = userService.findByUserName(getTokenUserName());
+
+        //对前端传的密码解密
+        if(param.getPassword().length() < 25){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4001, MsgCode.FAILURE_MSG_4001);
+        }
+        String password = Base64Converter.decode(Base64Converter.subText(param.getPassword()));
+        param.setPassword(password);
+
+        //对前端传的密码解密
+        if(param.getOldPassword().length() < 25){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4001, MsgCode.FAILURE_MSG_4001);
+        }
+        String oldPassword = Base64Converter.decode(Base64Converter.subText(param.getOldPassword()));
+        param.setOldPassword(oldPassword);
+
+
+        // 验证原密码
+        String encrypt = PasswordUtils.encrypt(userEntity.getUserName(), param.getOldPassword(), PasswordUtils.getStaticSalt());
+        if (!userEntity.getPassword().equals(encrypt)) {
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4002, MsgCode.FAILURE_MSG_4002);
+        }
+
+        if(!RegexUtils.validatePassword(param.getPassword())){
+            throw new BaseRuntimeException(MsgCode.FAILURE_CODE_4007, MsgCode.FAILURE_MSG_4007);
+        }
+
+        userEntity.setPassword(PasswordUtils.encrypt(userEntity.getUserName(), param.getPassword(), PasswordUtils.getStaticSalt()));
+        userService.update(userEntity);
+        return Result.success();
+    }
+
+    @ApiOperation("重置密码")
+    @GetMapping("resetPass/{id}")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "String", required = true)})
+    @WebControllerLog(description = "用户管理---重置密码")
+    @CheckCurrentUser()
+    public Result resetPass(@PathVariable String id){
+
+        UserEntity userEntity = userService.findById(id);
+        userEntity.setPassword(PasswordUtils.encrypt(userEntity.getUserName(), "Fcb20210225", PasswordUtils.getStaticSalt()));
+        userService.update(userEntity);
+        return Result.success();
+    }
+
+}

+ 130 - 0
4dkankan-user-web/src/main/java/com/fdkankan/web/shiro/JWTFilter.java

@@ -0,0 +1,130 @@
+package com.fdkankan.web.shiro;
+
+import lombok.extern.log4j.Log4j2;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.authc.AuthenticationException;
+import org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+
+/**
+ * 自定义拦截规则
+ */
+@Log4j2
+public class JWTFilter extends BasicHttpAuthenticationFilter {
+
+
+
+    /**
+     * 判断用户是否想要登入。
+     * 检测header里面是否包含Authorization字段即可
+     */
+    @Override
+    protected boolean isLoginAttempt(ServletRequest request, ServletResponse response) {
+        HttpServletRequest req = (HttpServletRequest) request;
+        String authorization = req.getHeader("Authorization");
+
+        if (StringUtils.isEmpty(authorization)) {
+            log.info("error Authorization is null");
+
+            // 先这样抛出异常,这个种不是接口的形式
+            throw new AuthenticationException("Authorization is null ");
+        }
+
+        return true;
+
+    }
+
+
+
+    /**
+     * 执行登录验证
+     */
+    @Override
+    protected boolean executeLogin(ServletRequest request, ServletResponse response) {
+//        LOGGER.warn("run executeLogin");
+        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
+        String authorization = httpServletRequest.getHeader("Authorization");
+        JWTToken token = new JWTToken(authorization);
+
+        // 判断token 是否跟redis
+
+        // 提交给realm进行登入,如果错误他会抛出异常并被捕获
+        getSubject(request, response).login(token);
+
+
+
+        // 如果没有抛出异常则代表登入成功,返回true
+        return true;
+    }
+
+    /**
+     * 这里我们详细说明下为什么最终返回的都是true,即允许访问
+     * 例如我们提供一个地址 GET /article
+     * 登入用户和游客看到的内容是不同的
+     * 如果在这里返回了false,请求会被直接拦截,用户看不到任何东西
+     * 所以我们在这里返回true,Controller中可以通过 subject.isAuthenticated() 来判断用户是否登入
+     * 如果有些资源只有登入用户才能访问,我们只需要在方法上面加上 @RequiresAuthentication 注解即可
+     * 但是这样做有一个缺点,就是不能够对GET,POST等请求进行分别过滤鉴权(因为我们重写了官方的方法),但实际上对应用影响不大
+     *
+     * owen:
+     *  return false ,表示全局拦截,必须登录才可以访问接口,除非配置了免拦截
+     *  "" @RequiresAuthentication 现在不需要配置这个注解来免登录
+     *
+     */
+    @Override
+    protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
+//        LOGGER.warn("run isAccessAllowed");
+        if (isLoginAttempt(request, response)) {
+//            try {
+//                executeLogin(request, response);
+//            } catch (Exception e) {
+////                response401(request, response);
+//                throw new AuthenticationException("Authorization is null 123");
+//            }
+
+            executeLogin(request, response);
+        }
+        // return false 前端没有响应,接收不到异常
+        return true;
+    }
+
+    /**
+     * 对跨域提供支持
+     * 只对需要token验证的有效,不需要验证的还是需要用注解处理一下
+     *
+     */
+    @Override
+    protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception {
+        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
+        HttpServletResponse httpServletResponse = (HttpServletResponse) response;
+        httpServletResponse.setHeader("Access-control-Allow-Origin", httpServletRequest.getHeader("Origin"));
+        httpServletResponse.setHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS,PUT,DELETE");
+        httpServletResponse.setHeader("Access-Control-Allow-Headers", httpServletRequest.getHeader("Access-Control-Request-Headers"));
+        // 跨域时会首先发送一个option请求,这里我们给option请求直接返回正常状态
+        if (httpServletRequest.getMethod().equals(RequestMethod.OPTIONS.name())) {
+            httpServletResponse.setStatus(HttpStatus.OK.value());
+            return false;
+        }
+        return super.preHandle(request, response);
+    }
+
+    /**
+     * 将非法请求跳转到 /401
+     */
+    private void response401(ServletRequest req, ServletResponse resp) {
+        try {
+            HttpServletResponse httpServletResponse = (HttpServletResponse) resp;
+            httpServletResponse.sendRedirect("/401");
+        } catch (IOException e) {
+            log.error(e.getMessage());
+        }
+    }
+}

+ 23 - 0
4dkankan-user-web/src/main/java/com/fdkankan/web/shiro/JWTToken.java

@@ -0,0 +1,23 @@
+package com.fdkankan.web.shiro;
+
+import org.apache.shiro.authc.AuthenticationToken;
+
+public class JWTToken implements AuthenticationToken {
+
+    // 密钥
+    private String token;
+
+    public JWTToken(String token) {
+        this.token = token;
+    }
+
+    @Override
+    public Object getPrincipal() {
+        return token;
+    }
+
+    @Override
+    public Object getCredentials() {
+        return token;
+    }
+}

+ 73 - 0
4dkankan-user-web/src/main/java/com/fdkankan/web/shiro/JWTUtil.java

@@ -0,0 +1,73 @@
+package com.fdkankan.web.shiro;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.JWTVerifier;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.exceptions.JWTDecodeException;
+import com.auth0.jwt.interfaces.DecodedJWT;
+import lombok.extern.log4j.Log4j2;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Date;
+
+@Log4j2
+public class JWTUtil {
+
+    // 过期时间24小时
+    private static final long EXPIRE_TIME = 24*60*60*1000;
+
+
+    /**
+     * 校验token是否正确
+     * @param token 密钥
+     * @param secret 用户的密码
+     * @return 是否正确
+     */
+    public static boolean verify(String token, String username, String secret) {
+        try {
+            Algorithm algorithm = Algorithm.HMAC256(secret);
+            JWTVerifier verifier = JWT.require(algorithm)
+                    .withClaim("username", username)
+                    .build();
+            DecodedJWT jwt = verifier.verify(token);
+            return true;
+        } catch (Exception e) {
+            e.getMessage();
+            log.error(e.getMessage());
+            return false;
+        }
+    }
+
+    /**
+     * 获得token中的信息无需secret解密也能获得
+     * @return token中包含的用户名
+     */
+    public static String getUsername(String token) {
+        try {
+            DecodedJWT jwt = JWT.decode(token);
+            return jwt.getClaim("username").asString();
+        } catch (JWTDecodeException e) {
+            return null;
+        }
+    }
+
+    /**
+     * 生成签名,5min后过期
+     * @param username 用户名
+     * @param secret 用户的密码
+     * @return 加密的token
+     */
+    public static String sign(String username, String secret) {
+        try {
+            Date date = new Date(System.currentTimeMillis()+EXPIRE_TIME);
+            Algorithm algorithm = Algorithm.HMAC256(secret);
+            // 附带username信息
+            return JWT.create()
+                    .withClaim("username", username)
+                    .withExpiresAt(date)
+                    .sign(algorithm);
+        } catch (UnsupportedEncodingException e) {
+            return null;
+        }
+    }
+}

+ 151 - 0
4dkankan-user-web/src/main/java/com/fdkankan/web/shiro/MyRealm.java

@@ -0,0 +1,151 @@
+package com.fdkankan.web.shiro;
+
+import com.fdkankan.domain.backend.ResourceEntity;
+import com.fdkankan.domain.backend.RoleEntity;
+import com.fdkankan.domain.backend.UserEntity;
+import com.fdkankan.service.backend.ResourceService;
+import com.fdkankan.service.backend.RoleService;
+import com.fdkankan.service.backend.UserService;
+import lombok.extern.log4j.Log4j2;
+import org.apache.shiro.authc.AuthenticationException;
+import org.apache.shiro.authc.AuthenticationInfo;
+import org.apache.shiro.authc.AuthenticationToken;
+import org.apache.shiro.authc.SimpleAuthenticationInfo;
+import org.apache.shiro.authz.AuthorizationInfo;
+import org.apache.shiro.authz.SimpleAuthorizationInfo;
+import org.apache.shiro.realm.AuthorizingRealm;
+import org.apache.shiro.subject.PrincipalCollection;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Service;
+
+import java.math.BigInteger;
+import java.util.*;
+
+/**
+ * 配置不校验的话,是不会走这个方法的
+ */
+@Log4j2
+@Service
+public class MyRealm extends AuthorizingRealm {
+
+
+//    @Autowired
+//    private UserRepository userRepository;
+//
+    @Autowired
+//    private RedisTemplate redisTemplate;
+    private RedisTemplate<String, String> redisTemplate;
+
+    @Autowired
+    private UserService userService;
+
+    @Autowired
+    private RoleService roleService;
+
+    @Autowired
+    private ResourceService resourceService;
+
+
+
+    /**
+     * 大坑!,必须重写此方法,不然Shiro会报错
+     */
+    @Override
+    public boolean supports(AuthenticationToken token) {
+        return token instanceof JWTToken;
+    }
+
+    /**
+     * 只有当需要检测用户权限的时候才会调用此方法,例如checkRole,checkPermission之类的
+     *
+     * principals: 是token
+     */
+    @Override
+    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
+        String username = JWTUtil.getUsername(principals.toString());
+        UserEntity dbUserEntity = userService.findByUserName(username);
+
+        SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo();
+
+        Map<String, Set<String>> resultMap = getRole(dbUserEntity);
+        Set<String> rolekeys = resultMap.get("role");
+
+
+        // 获取用户权限
+        Set<String> permissions = new HashSet<>();
+        try {
+            List<ResourceEntity> userPermissionList = resourceService.getResourcesByUserPermission(dbUserEntity);
+            for (ResourceEntity i : userPermissionList) {
+                permissions.add(i.getResourceKey());
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        // 设置角色、权限
+        simpleAuthorizationInfo.addRoles(rolekeys);
+        simpleAuthorizationInfo.addStringPermissions(permissions);
+        return simpleAuthorizationInfo;
+    }
+
+    /**
+     * 获取角色相关信息
+     */
+    private Map<String, Set<String>> getRole(UserEntity userEntity){
+
+        Set<String> roleIds = userService.findUserRoleByUserId(userEntity.getId());
+        Set<String> roleKeys = new HashSet<>();
+        for (String i : roleIds) {
+            RoleEntity dbRoleEntity = roleService.findById(i);
+            roleKeys.add(dbRoleEntity.getRoleKey());
+        }
+
+        HashMap<String, Set<String>> resultMap = new HashMap<>();
+        resultMap.put("role", roleKeys);
+
+        return resultMap;
+    }
+
+    /**
+     * 默认使用此方法进行用户名正确与否验证,错误抛出异常即可。
+     */
+    @Override
+    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {
+//        log.warn("run doGetAuthenticationInfo");
+        String token = (String) auth.getCredentials();
+        log.warn("token: {}", token);
+        // 解密获得username,用于和数据库进行对比
+        String username = JWTUtil.getUsername(token);
+        if (username == null) {
+            log.info("error token username");
+            throw new AuthenticationException("token invalid");
+        }
+
+        UserEntity userEntity = userService.findByUserName(username);
+        if (userEntity == null) {
+            log.info("error token userEntity");
+            throw new AuthenticationException("UserEntity didn't existed!");
+        }
+
+        // 校验请求token是否跟redis token一致
+        String redisToken = (String) redisTemplate.opsForValue().get(userEntity.getUserName());
+        log.warn("redisToken: {}", redisToken);
+        if (!token.equals(redisToken)) {
+            log.info("error token redis");
+//            throw new AuthenticationException("token invalid");
+            throw new AuthenticationException("token invalid");
+
+        }
+
+
+        if (! JWTUtil.verify(token, username, userEntity.getPassword())) {
+            log.info("error token username or password");
+            throw new AuthenticationException("token invalid");
+        }
+
+//        log.warn("end doGetAuthenticationInfo");
+
+        return new SimpleAuthenticationInfo(token, token, "my_realm");
+    }
+}

+ 172 - 0
4dkankan-user-web/src/main/java/com/fdkankan/web/shiro/ShiroConfig.java

@@ -0,0 +1,172 @@
+package com.fdkankan.web.shiro;
+
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.alibaba.fastjson.support.config.FastJsonConfig;
+import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
+import lombok.extern.log4j.Log4j2;
+import org.apache.shiro.mgt.DefaultSessionStorageEvaluator;
+import org.apache.shiro.mgt.DefaultSubjectDAO;
+import org.apache.shiro.spring.LifecycleBeanPostProcessor;
+import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
+import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
+import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
+import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
+import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.DependsOn;
+import org.springframework.http.MediaType;
+
+import javax.servlet.Filter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Log4j2
+@Configuration
+public class ShiroConfig {
+
+//    @Value("${spring.redis.host}")
+//    private String host;
+//
+//    @Value("${spring.redis.port}")
+//    private int port;
+//
+//    @Value("${spring.redis.jedis.timeout}")
+//    private int timeout;
+
+    @Bean("securityManager")
+    public DefaultWebSecurityManager getManager(MyRealm realm) {
+        DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
+        // 使用自己的realm
+        manager.setRealm(realm);
+
+        /*
+         * 关闭shiro自带的session,详情见文档
+         * http://shiro.apache.org/session-management.html#SessionManagement-StatelessApplications%28Sessionless%29
+         */
+        DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
+        DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator();
+        defaultSessionStorageEvaluator.setSessionStorageEnabled(false);
+        subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator);
+        manager.setSubjectDAO(subjectDAO);
+
+        return manager;
+    }
+
+    @Bean("shiroFilter")
+    public ShiroFilterFactoryBean factory(DefaultWebSecurityManager securityManager) {
+        ShiroFilterFactoryBean factoryBean = new ShiroFilterFactoryBean();
+
+        // 添加自己的过滤器并且取名为jwt
+        Map<String, Filter> filterMap = new HashMap<>();
+        filterMap.put("jwt", new JWTFilter());
+
+
+
+
+        factoryBean.setFilters(filterMap);
+
+        factoryBean.setSecurityManager(securityManager);
+        factoryBean.setUnauthorizedUrl("/401");
+
+        /*
+         * 自定义url规则
+         * http://shiro.apache.org/web.html#urls-
+         */
+        Map<String, String> filterRuleMap = new HashMap<>();
+
+        // 不拦截
+        filterRuleMap.put("/login", "anon");
+        filterRuleMap.put("/logout", "anon");
+        filterRuleMap.put("/admin", "anon");
+        filterRuleMap.put("/admin/login", "anon");
+        filterRuleMap.put("/test/**", "anon");
+        filterRuleMap.put("/manage/**", "anon");
+
+//        filterRuleMap.put("/api/dem/**", "anon");
+//        filterRuleMap.put("/test/convert/**", "anon");
+//        filterRuleMap.put("/api/convert/**", "anon");
+
+
+        // swagger 不拦截
+        filterRuleMap.put("/swagger-resources/**", "anon");
+        filterRuleMap.put("/webjars/**", "anon");
+        filterRuleMap.put("/v2/**", "anon");
+        filterRuleMap.put("/swagger-ui.html/**", "anon");
+
+
+        // 所有请求通过我们自己的JWT Filter
+//        filterRuleMap.put("/api/manage/**", "jwt");
+
+
+        // 访问401和404页面不通过我们的Filter
+        filterRuleMap.put("/401", "anon");
+        factoryBean.setFilterChainDefinitionMap(filterRuleMap);
+        return factoryBean;
+    }
+
+    /**
+     * 下面的代码是添加注解支持
+     */
+    @Bean
+    @DependsOn("lifecycleBeanPostProcessor")
+    public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
+        DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
+        // 强制使用cglib,防止重复代理和可能引起代理出错的问题
+        // https://zhuanlan.zhihu.com/p/29161098
+        defaultAdvisorAutoProxyCreator.setProxyTargetClass(true);
+        return defaultAdvisorAutoProxyCreator;
+    }
+
+    @Bean
+    public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
+        return new LifecycleBeanPostProcessor();
+    }
+
+    @Bean
+    public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(DefaultWebSecurityManager securityManager) {
+        AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor();
+        advisor.setSecurityManager(securityManager);
+        return advisor;
+    }
+
+
+    /**
+     * fastJson相关设置
+     * Dto包含json,需要配置不然会异常
+     * @return
+     */
+    @Bean
+    public HttpMessageConverters customConverters() {
+//        log.warn("run customConverters");
+
+
+        FastJsonHttpMessageConverter fastJson = new FastJsonHttpMessageConverter();
+
+        // 创建FastJson信息转换对象
+        FastJsonConfig fastJsonConfig = new FastJsonConfig();
+
+
+        // 设置全程返回时间
+        fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
+        // 设置返回值为null是时输出,不写的话,null 字段 不返回。也可以设置返回空串
+        fastJsonConfig.setSerializerFeatures(SerializerFeature.WriteNullStringAsEmpty);
+        fastJson.setFastJsonConfig(fastJsonConfig);
+
+        //3、中文乱码解决方案
+        List<MediaType> mediaTypeList = new ArrayList<>();
+        mediaTypeList.add(MediaType.APPLICATION_JSON_UTF8);
+        mediaTypeList.add(MediaType.valueOf("text/html;charset=UTF-8"));
+
+
+        //4、将转换规则应用于转换对象
+        fastJson.setSupportedMediaTypes(mediaTypeList);
+
+
+        return new HttpMessageConverters(fastJson);
+    }
+
+
+}

+ 193 - 0
pom.xml

@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <!-- fdkankan parent-->
+    <groupId>com.fdkankan</groupId>
+    <artifactId>fdkankan</artifactId>
+    <packaging>pom</packaging>
+    <version>1.0-SNAPSHOT</version>
+
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.1.0.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+
+    <!-- 模块说明:这里声明多个子模块 -->
+    <modules>
+        <module>4dkankan-user-application</module>
+        <module>4dkankan-user-common</module>
+        <module>4dkankan-user-web</module>
+        <module>4dkankan-user-dao</module>
+        <module>4dkankan-user-service</module>
+        <module>4dkankan-user-domain</module>
+    </modules>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <java.version>1.8</java.version>
+        <spring.boot.version>2.1.0.RELEASE</spring.boot.version>
+        <fdkankan.version>1.0.0</fdkankan.version>
+        <fastjson.version>1.2.51</fastjson.version>
+        <druid.version>1.1.14</druid.version>
+        <hutool.version>5.1.0</hutool.version>
+        <lombok.version>1.18.2</lombok.version>
+        <lang3.version>3.7</lang3.version>
+        <mysql.version>8.0.15</mysql.version>
+        <swagger2.version>2.9.2</swagger2.version>
+        <shiro.version>1.4.0</shiro.version>
+        <jwt.version>3.2.0</jwt.version>
+        <nacos-config-spring-boot.version>0.2.1</nacos-config-spring-boot.version>
+
+    </properties>
+
+
+    <!--dependencyManagement用于管理依赖版本号, 必须写版本号,不然依赖不上-->
+    <dependencyManagement>
+        <dependencies>
+            <!--模块版本管理-->
+            <dependency>
+                <groupId>com.fdkankan</groupId>
+                <artifactId>4dkankan-user-common</artifactId>
+                <version>${fdkankan.version}</version>
+            </dependency>
+
+            <dependency>
+                <groupId>com.fdkankan</groupId>
+                <artifactId>4dkankan-user-domain</artifactId>
+                <version>${fdkankan.version}</version>
+            </dependency>
+
+            <dependency>
+                <groupId>com.fdkankan</groupId>
+                <artifactId>4dkankan-user-service</artifactId>
+                <version>${fdkankan.version}</version>
+            </dependency>
+
+            <dependency>
+                <groupId>com.fdkankan</groupId>
+                <artifactId>4dkankan-user-dao</artifactId>
+                <version>${fdkankan.version}</version>
+            </dependency>
+
+            <dependency>
+                <groupId>com.fdkankan</groupId>
+                <artifactId>4dkankan-user-web</artifactId>
+                <version>${fdkankan.version}</version>
+            </dependency>
+
+
+            <!-- springboot -->
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-starter-data-jpa</artifactId>
+                <version>${spring.boot.version}</version>
+            </dependency>
+
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-starter-web</artifactId>
+                <version>${spring.boot.version}</version>
+            </dependency>
+
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-starter-test</artifactId>
+                <scope>test</scope>
+                <version>${spring.boot.version}</version>
+            </dependency>
+
+            <!--springboot中的redis依赖-->
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-starter-data-redis</artifactId>
+                <version>${spring.boot.version}</version>
+            </dependency>
+
+            <!-- lombok -->
+            <dependency>
+                <groupId>org.projectlombok</groupId>
+                <artifactId>lombok</artifactId>
+                <version>${lombok.version}</version>
+            </dependency>
+
+            <!-- fastjson -->
+            <dependency>
+                <groupId>com.alibaba</groupId>
+                <artifactId>fastjson</artifactId>
+                <version>${fastjson.version}</version>
+            </dependency>
+
+            <!--阿里数据库连接池 -->
+            <dependency>
+                <groupId>com.alibaba</groupId>
+                <artifactId>druid-spring-boot-starter</artifactId>
+                <version>${druid.version}</version>
+            </dependency>
+
+            <!-- mysql -->
+            <dependency>
+                <groupId>mysql</groupId>
+                <artifactId>mysql-connector-java</artifactId>
+                <version>${mysql.version}</version>
+            </dependency>
+
+            <!-- 工具类 -->
+            <dependency>
+                <groupId>cn.hutool</groupId>
+                <artifactId>hutool-all</artifactId>
+                <version>${hutool.version}</version>
+            </dependency>
+
+            <!-- StringUtils -->
+            <dependency>
+                <groupId>org.apache.commons</groupId>
+                <artifactId>commons-lang3</artifactId>
+                <version>${lang3.version}</version>
+            </dependency>
+
+            <!--swagger2核心包和swagger-ui界面包-->
+            <dependency>
+                <groupId>io.springfox</groupId>
+                <artifactId>springfox-swagger2</artifactId>
+                <version>${swagger2.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>io.springfox</groupId>
+                <artifactId>springfox-swagger-ui</artifactId>
+                <version>${swagger2.version}</version>
+            </dependency>
+
+            <!-- shiro -->
+            <dependency>
+                <groupId>org.apache.shiro</groupId>
+                <artifactId>shiro-spring</artifactId>
+                <version>${shiro.version}</version>
+            </dependency>
+
+
+            <!-- jwt -->
+            <dependency>
+                <groupId>com.auth0</groupId>
+                <artifactId>java-jwt</artifactId>
+                <version>${jwt.version}</version>
+            </dependency>
+
+            <!-- kaptcha -->
+            <dependency>
+                <groupId>com.github.penggle</groupId>
+                <artifactId>kaptcha</artifactId>
+                <version>${kaptcha.version}</version>
+            </dependency>
+
+
+        </dependencies>
+    </dependencyManagement>
+
+
+</project>