mirror of
https://gitee.com/orangeform/orange-admin.git
synced 2026-01-17 18:46:36 +08:00
commit:同步2.0版本(添加指定审批人功能)
This commit is contained in:
@@ -0,0 +1,232 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="Spring" name="Spring">
|
||||
<configuration />
|
||||
</facet>
|
||||
<facet type="web" name="Web">
|
||||
<configuration>
|
||||
<webroots />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" generated="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="common-core" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.45" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.glassfish:jakarta.el:3.0.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.45" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:29.0-jre" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.checkerframework:checker-qual:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.3.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.3.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-csv:1.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.6.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.jsonwebtoken:jjwt:0.9.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.76" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.ben-manes.caffeine:caffeine:2.8.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: cn.jimmyshi:bean-query:1.1.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-all:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.30" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml:3.17" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi:3.17" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:3.17" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:2.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: stax:stax-api:1.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.virtuald:curvesapi:1.04" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: mysql:mysql-connector-java:8.0.23" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:druid-spring-boot-starter:1.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:druid:1.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-boot-starter:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-extension:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-core:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-annotation:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.2.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:3.2" level="project" />
|
||||
<orderEntry type="module" module-name="common-redis" />
|
||||
<orderEntry type="library" name="Maven: org.redisson:redisson:3.15.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.63.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.63.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.63.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.63.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.63.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-resolver-dns:4.1.63.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-codec-dns:4.1.63.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.63.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.cache:cache-api:1.1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:3.3.16.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.reactivex.rxjava3:rxjava:3.0.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.marshalling:jboss-marshalling-river:2.0.11.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.marshalling:jboss-marshalling:2.0.11.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.10.22" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jodd:jodd-bean:5.1.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jodd:jodd-core:5.1.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-freemarker:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.freemarker:freemarker:2.3.31" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:4.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-log4j2:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.13.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.13.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.13.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-jul:2.13.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.30" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.9.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-cache:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-configuration-processor:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-actuator:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-actuator-autoconfigure:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-actuator:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.micrometer:micrometer-core:1.5.13" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hdrhistogram:HdrHistogram:2.1.12" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.latencyutils:LatencyUtils:2.0.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: de.codecentric:spring-boot-admin-starter-client:2.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: de.codecentric:spring-boot-admin-client:2.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-config:2.2.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.spring:spring-context-support:1.0.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.nacos:nacos-client:1.4.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.nacos:nacos-common:1.4.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpasyncclient:4.1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore-nio:4.4.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.nacos:nacos-api:1.4.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.prometheus:simpleclient:0.5.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-commons:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-crypto:5.3.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-context:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-openfeign:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-rsa:1.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.59" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.59" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-openfeign-core:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign.form:feign-form-spring:3.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign.form:feign-form:3.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign:feign-core:10.10.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign:feign-slf4j:10.10.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign:feign-hystrix:10.10.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.netflix.archaius:archaius-core:0.7.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign:feign-httpclient:10.10.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.13" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-netflix-hystrix:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-netflix-hystrix:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-netflix-ribbon:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-netflix-archaius:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-netflix-archaius:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-configuration:commons-configuration:1.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.netflix.hystrix:hystrix-core:1.5.18" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.reactivex:rxjava:1.3.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.netflix.hystrix:hystrix-serialization:1.5.18" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: com.fasterxml.jackson.module:jackson-module-afterburner:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.netflix.hystrix:hystrix-metrics-event-stream:1.5.18" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.netflix.hystrix:hystrix-javanica:1.5.18" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.reactivex:rxjava-reactive-streams:1.2.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.2.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.4.1.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.4.2.Final" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mapstruct:mapstruct-processor:1.4.2.Final" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.20" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.curator:curator-recipes:4.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.curator:curator-framework:4.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.curator:curator-client:4.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.zookeeper:zookeeper:3.5.3-beta" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-cli:commons-cli:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.kafka:kafka-clients:2.4.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.luben:zstd-jni:1.4.3-1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.lz4:lz4-java:1.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.xerial.snappy:snappy-java:1.1.7.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.scala-lang:scala-library:2.12.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.lmax:disruptor:3.4.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:2.0.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:2.0.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: jakarta.xml.bind:jakarta.xml.bind-api:2.3.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: jakarta.activation:jakarta.activation-api:1.2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.16.1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest:2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter:5.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-params:5.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.vintage:junit-vintage-engine:5.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.13.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:3.3.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.10.22" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-junit-jupiter:3.3.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.7.0" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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>common</artifactId>
|
||||
<groupId>com.orange.demo</groupId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>common-datafilter</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>common-datafilter</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.orange.demo</groupId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.orange.demo</groupId>
|
||||
<artifactId>common-redis</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.orange.demo.common.datafilter.aop;
|
||||
|
||||
import com.orange.demo.common.core.object.GlobalThreadLocal;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 禁用Mybatis拦截器数据过滤的AOP处理类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
@Order(1)
|
||||
@Slf4j
|
||||
public class DisableDataFilterAspect {
|
||||
|
||||
/**
|
||||
* 所有标记了DisableDataFilter注解的方法。
|
||||
*/
|
||||
@Pointcut("@annotation(com.orange.demo.common.core.annotation.DisableDataFilter)")
|
||||
public void disableDataFilterPointCut() {
|
||||
// 空注释,避免sonar警告
|
||||
}
|
||||
|
||||
@Around("disableDataFilterPointCut()")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
boolean dataFilterEnabled = GlobalThreadLocal.setDataFilter(false);
|
||||
try {
|
||||
return point.proceed();
|
||||
} finally {
|
||||
GlobalThreadLocal.setDataFilter(dataFilterEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.orange.demo.common.datafilter.config;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
|
||||
/**
|
||||
* common-datafilter模块的自动配置引导类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@EnableConfigurationProperties({DataFilterProperties.class})
|
||||
public class DataFilterAutoConfig {
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.orange.demo.common.datafilter.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* common-datafilter模块的配置类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "datafilter")
|
||||
public class DataFilterProperties {
|
||||
|
||||
/**
|
||||
* 是否启用租户过滤。
|
||||
*/
|
||||
@Value("${datafilter.tenant.enabled:false}")
|
||||
private Boolean enabledTenantFilter;
|
||||
|
||||
/**
|
||||
* 是否启动数据权限过滤。
|
||||
*/
|
||||
@Value("${datafilter.dataperm.enabled:false}")
|
||||
private Boolean enabledDataPermFilter;
|
||||
|
||||
/**
|
||||
* 部门关联表的表名前缀,如zz_。该值主要用在MybatisDataFilterInterceptor拦截器中,
|
||||
* 用于拼接数据权限过滤的SQL语句。
|
||||
*/
|
||||
@Value("${datafilter.dataperm.deptRelationTablePrefix:}")
|
||||
private String deptRelationTablePrefix;
|
||||
|
||||
/**
|
||||
* 该值为true的时候,在进行数据权限过滤时,会加上表名,如:zz_sys_user.dept_id = xxx。
|
||||
* 为false时,过滤条件不加表名,只是使用字段名,如:dept_id = xxx。该值目前主要适用于
|
||||
* Oracle分页SQL使用了子查询的场景。此场景下,由于子查询使用了别名,再在数据权限过滤条件中
|
||||
* 加上原有表名时,SQL语法会报错。
|
||||
*/
|
||||
@Value("${datafilter.dataperm.addTableNamePrefix:true}")
|
||||
private Boolean addTableNamePrefix;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.orange.demo.common.datafilter.config;
|
||||
|
||||
import com.orange.demo.common.datafilter.interceptor.DataFilterInterceptor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* 添加数据过滤相关的拦截器。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Configuration
|
||||
public class DataFilterWebMvcConfigurer implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new DataFilterInterceptor()).addPathPatterns("/**");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.orange.demo.common.datafilter.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据权限规则类型常量类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
public final class DataPermRuleType {
|
||||
|
||||
/**
|
||||
* 查看全部。
|
||||
*/
|
||||
public static final int TYPE_ALL = 0;
|
||||
|
||||
/**
|
||||
* 仅查看当前用户
|
||||
*/
|
||||
public static final int TYPE_USER_ONLY = 1;
|
||||
|
||||
/**
|
||||
* 仅查看当前部门
|
||||
*/
|
||||
public static final int TYPE_DEPT_ONLY = 2;
|
||||
|
||||
/**
|
||||
* 所在部门及子部门
|
||||
*/
|
||||
public static final int TYPE_DEPT_AND_CHILD_DEPT = 3;
|
||||
|
||||
/**
|
||||
* 多部门及子部门
|
||||
*/
|
||||
public static final int TYPE_MULTI_DEPT_AND_CHILD_DEPT = 4;
|
||||
|
||||
/**
|
||||
* 自定义部门列表
|
||||
*/
|
||||
public static final int TYPE_CUSTOM_DEPT_LIST = 5;
|
||||
|
||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(6);
|
||||
static {
|
||||
DICT_MAP.put(0, "查看全部");
|
||||
DICT_MAP.put(1, "仅查看当前用户");
|
||||
DICT_MAP.put(2, "仅查看所在部门");
|
||||
DICT_MAP.put(3, "所在部门及子部门");
|
||||
DICT_MAP.put(4, "多部门及子部门");
|
||||
DICT_MAP.put(5, "自定义部门列表");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断参数是否为当前常量字典的合法取值范围。
|
||||
*
|
||||
* @param value 待验证的参数值。
|
||||
* @return 合法返回true,否则false。
|
||||
*/
|
||||
public static boolean isValid(Integer value) {
|
||||
return value != null && DICT_MAP.containsKey(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私有构造函数,明确标识该常量类的作用。
|
||||
*/
|
||||
private DataPermRuleType() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.orange.demo.common.datafilter.interceptor;
|
||||
|
||||
import com.orange.demo.common.core.object.GlobalThreadLocal;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 主要用于初始化,通过Mybatis拦截器插件进行数据过滤的标记。
|
||||
* 在调用controller接口处理方法之前,必须强制将数据过滤标记设置为缺省值。
|
||||
* 这样可以避免使用当前线程在处理上一个请求时,未能正常清理的数据过滤标记值。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Slf4j
|
||||
public class DataFilterInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
// 每次进入Controller接口之前,均主动打开数据权限验证。
|
||||
// 可以避免该Servlet线程在处理之前的请求时异常退出,从而导致该状态数据没有被正常清除。
|
||||
GlobalThreadLocal.setDataFilter(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
|
||||
ModelAndView modelAndView) throws Exception {
|
||||
// 这里需要加注释,否则sonar不happy。
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
|
||||
throws Exception {
|
||||
GlobalThreadLocal.clearDataFilter();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,469 @@
|
||||
package com.orange.demo.common.datafilter.interceptor;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.annotation.*;
|
||||
import com.orange.demo.common.core.exception.NoDataPermException;
|
||||
import com.orange.demo.common.core.object.GlobalThreadLocal;
|
||||
import com.orange.demo.common.core.object.TokenData;
|
||||
import com.orange.demo.common.core.util.ApplicationContextHolder;
|
||||
import com.orange.demo.common.core.util.ContextUtil;
|
||||
import com.orange.demo.common.core.util.MyModelUtil;
|
||||
import com.orange.demo.common.core.util.RedisKeyUtil;
|
||||
import com.orange.demo.common.datafilter.config.DataFilterProperties;
|
||||
import com.orange.demo.common.datafilter.constant.DataPermRuleType;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.jsqlparser.JSQLParserException;
|
||||
import net.sf.jsqlparser.expression.operators.conditional.AndExpression;
|
||||
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
|
||||
import net.sf.jsqlparser.statement.Statement;
|
||||
import net.sf.jsqlparser.statement.delete.Delete;
|
||||
import net.sf.jsqlparser.statement.select.FromItem;
|
||||
import net.sf.jsqlparser.statement.select.PlainSelect;
|
||||
import net.sf.jsqlparser.statement.select.Select;
|
||||
import net.sf.jsqlparser.statement.select.SubSelect;
|
||||
import net.sf.jsqlparser.statement.update.Update;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.executor.statement.RoutingStatementHandler;
|
||||
import org.apache.ibatis.executor.statement.StatementHandler;
|
||||
import org.apache.ibatis.mapping.BoundSql;
|
||||
import org.apache.ibatis.mapping.MappedStatement;
|
||||
import org.apache.ibatis.mapping.SqlCommandType;
|
||||
import org.apache.ibatis.plugin.*;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.sql.Connection;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Mybatis拦截器。目前用于数据权限的统一拦截和注入处理。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})})
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MybatisDataFilterInterceptor implements Interceptor {
|
||||
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
@Autowired
|
||||
private DataFilterProperties properties;
|
||||
|
||||
/**
|
||||
* 对象缓存。由于Set是排序后的,因此在查找排除方法名称时效率更高。
|
||||
* 在应用服务启动的监听器中(LoadDataPermMapperListener),会调用当前对象的(loadMappersWithDataPerm)方法,加载缓存。
|
||||
*/
|
||||
private final Map<String, ModelDataPermInfo> cachedDataPermMap = new HashMap<>();
|
||||
/**
|
||||
* 租户租户对象缓存。
|
||||
*/
|
||||
private final Map<String, ModelTenantInfo> cachedTenantMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 预先加载与数据过滤相关的数据到缓存,该函数会在(LoadDataFilterInfoListener)监听器中调用。
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public void loadInfoWithDataFilter() {
|
||||
Map<String, BaseDaoMapper> mapperMap =
|
||||
ApplicationContextHolder.getApplicationContext().getBeansOfType(BaseDaoMapper.class);
|
||||
for (BaseDaoMapper<?> mapperProxy : mapperMap.values()) {
|
||||
// 优先处理jdk的代理
|
||||
Object proxy = ReflectUtil.getFieldValue(mapperProxy, "h");
|
||||
// 如果不是jdk的代理,再看看cjlib的代理。
|
||||
if (proxy == null) {
|
||||
proxy = ReflectUtil.getFieldValue(mapperProxy, "CGLIB$CALLBACK_0");
|
||||
}
|
||||
Class<?> mapperClass = (Class<?>) ReflectUtil.getFieldValue(proxy, "mapperInterface");
|
||||
if (properties.getEnabledTenantFilter()) {
|
||||
loadTenantFilterData(mapperClass);
|
||||
}
|
||||
if (properties.getEnabledDataPermFilter()) {
|
||||
EnableDataPerm rule = mapperClass.getAnnotation(EnableDataPerm.class);
|
||||
if (rule != null) {
|
||||
loadDataPermFilterRules(mapperClass, rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadTenantFilterData(Class<?> mapperClass) {
|
||||
Class<?> modelClass = (Class<?>) ((ParameterizedType)
|
||||
mapperClass.getGenericInterfaces()[0]).getActualTypeArguments()[0];
|
||||
Field[] fields = ReflectUtil.getFields(modelClass);
|
||||
for (Field field : fields) {
|
||||
if (field.getAnnotation(TenantFilterColumn.class) != null) {
|
||||
ModelTenantInfo tenantInfo = new ModelTenantInfo();
|
||||
tenantInfo.setModelName(modelClass.getSimpleName());
|
||||
tenantInfo.setTableName(modelClass.getAnnotation(TableName.class).value());
|
||||
tenantInfo.setFieldName(field.getName());
|
||||
tenantInfo.setColumnName(MyModelUtil.mapToColumnName(field, modelClass));
|
||||
// 判断当前dao中是否包括不需要自动注入租户Id过滤的方法。
|
||||
DisableTenantFilter disableTenantFilter = mapperClass.getAnnotation(DisableTenantFilter.class);
|
||||
if (disableTenantFilter != null) {
|
||||
// 这里开始获取当前Mapper已经声明的的SqlId中,有哪些是需要排除在外的。
|
||||
// 排除在外的将不进行数据过滤。
|
||||
Set<String> excludeMethodNameSet = new HashSet<>();
|
||||
for (String excludeName : disableTenantFilter.includeMethodName()) {
|
||||
excludeMethodNameSet.add(excludeName);
|
||||
// 这里是给pagehelper中,分页查询先获取数据总量的查询。
|
||||
excludeMethodNameSet.add(excludeName + "_COUNT");
|
||||
}
|
||||
tenantInfo.setExcludeMethodNameSet(excludeMethodNameSet);
|
||||
}
|
||||
cachedTenantMap.put(mapperClass.getName(), tenantInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadDataPermFilterRules(Class<?> mapperClass, EnableDataPerm rule) {
|
||||
String sysDataPermMapperName = "SysDataPermMapper";
|
||||
// 由于给数据权限Mapper添加@EnableDataPerm,将会导致无限递归,因此这里检测到之后,
|
||||
// 会在系统启动加载监听器的时候,及时抛出异常。
|
||||
if (StringUtils.equals(sysDataPermMapperName, mapperClass.getSimpleName())) {
|
||||
throw new IllegalStateException("Add @EnableDataPerm annotation to SysDataPermMapper is ILLEGAL!");
|
||||
}
|
||||
// 这里开始获取当前Mapper已经声明的的SqlId中,有哪些是需要排除在外的。
|
||||
// 排除在外的将不进行数据过滤。
|
||||
Set<String> excludeMethodNameSet = null;
|
||||
String[] excludes = rule.excluseMethodName();
|
||||
if (excludes.length > 0) {
|
||||
excludeMethodNameSet = new HashSet<>();
|
||||
for (String excludeName : excludes) {
|
||||
excludeMethodNameSet.add(excludeName);
|
||||
// 这里是给pagehelper中,分页查询先获取数据总量的查询。
|
||||
excludeMethodNameSet.add(excludeName + "_COUNT");
|
||||
}
|
||||
}
|
||||
// 获取Mapper关联的主表信息,包括表名,user过滤字段名和dept过滤字段名。
|
||||
Class<?> modelClazz = (Class<?>)
|
||||
((ParameterizedType) mapperClass.getGenericInterfaces()[0]).getActualTypeArguments()[0];
|
||||
Field[] fields = ReflectUtil.getFields(modelClazz);
|
||||
Field userFilterField = null;
|
||||
Field deptFilterField = null;
|
||||
for (Field field : fields) {
|
||||
if (null != field.getAnnotation(UserFilterColumn.class)) {
|
||||
userFilterField = field;
|
||||
}
|
||||
if (null != field.getAnnotation(DeptFilterColumn.class)) {
|
||||
deptFilterField = field;
|
||||
}
|
||||
if (userFilterField != null && deptFilterField != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 通过注解解析与Mapper关联的Model,并获取与数据权限关联的信息,并将结果缓存。
|
||||
ModelDataPermInfo info = new ModelDataPermInfo();
|
||||
info.setMainTableName(MyModelUtil.mapToTableName(modelClazz));
|
||||
info.setExcludeMethodNameSet(excludeMethodNameSet);
|
||||
if (userFilterField != null) {
|
||||
info.setUserFilterColumn(MyModelUtil.mapToColumnName(userFilterField, modelClazz));
|
||||
}
|
||||
if (deptFilterField != null) {
|
||||
info.setDeptFilterColumn(MyModelUtil.mapToColumnName(deptFilterField, modelClazz));
|
||||
}
|
||||
cachedDataPermMap.put(mapperClass.getName(), info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object intercept(Invocation invocation) throws Throwable {
|
||||
// 判断当前线程本地存储中,业务操作是否禁用了数据权限过滤,如果禁用,则不进行后续的数据过滤处理了。
|
||||
if (!GlobalThreadLocal.enabledDataFilter()) {
|
||||
return invocation.proceed();
|
||||
}
|
||||
// 只有在HttpServletRequest场景下,该拦截器才起作用,对于系统级别的预加载数据不会应用数据权限。
|
||||
if (!ContextUtil.hasRequestContext()) {
|
||||
return invocation.proceed();
|
||||
}
|
||||
// 没有登录的用户,不会参与租户过滤,如果需要过滤的,自己在代码中手动实现
|
||||
// 通常对于无需登录的白名单url,也无需过滤了。
|
||||
// 另外就是登录接口中,获取菜单列表的接口,由于尚未登录,没有TokenData,所以这个接口我们手动加入了该条件。
|
||||
if (TokenData.takeFromRequest() == null) {
|
||||
return invocation.proceed();
|
||||
}
|
||||
RoutingStatementHandler handler = (RoutingStatementHandler) invocation.getTarget();
|
||||
StatementHandler delegate =
|
||||
(StatementHandler) ReflectUtil.getFieldValue(handler, "delegate");
|
||||
// 通过反射获取delegate父类BaseStatementHandler的mappedStatement属性
|
||||
MappedStatement mappedStatement =
|
||||
(MappedStatement) ReflectUtil.getFieldValue(delegate, "mappedStatement");
|
||||
SqlCommandType commandType = mappedStatement.getSqlCommandType();
|
||||
// 对于INSERT语句,我们不进行任何数据过滤。
|
||||
if (commandType == SqlCommandType.INSERT) {
|
||||
return invocation.proceed();
|
||||
}
|
||||
String sqlId = mappedStatement.getId();
|
||||
int pos = StringUtils.lastIndexOf(sqlId, ".");
|
||||
String className = StringUtils.substring(sqlId, 0, pos);
|
||||
String methodName = StringUtils.substring(sqlId, pos + 1);
|
||||
// 先进行租户过滤条件的处理,再将解析并处理后的SQL Statement交给下一步的数据权限过滤去处理。
|
||||
// 这样做的目的主要是为了减少一次SQL解析的过程,因为这是高频操作,所以要尽量去优化。
|
||||
Statement statement = null;
|
||||
if (properties.getEnabledTenantFilter()) {
|
||||
statement = this.processTenantFilter(className, methodName, delegate.getBoundSql(), commandType);
|
||||
}
|
||||
// 处理数据权限过滤。
|
||||
if (properties.getEnabledDataPermFilter()) {
|
||||
this.processDataPermFilter(className, methodName, delegate.getBoundSql(), commandType, statement, sqlId);
|
||||
}
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
private Statement processTenantFilter(
|
||||
String className, String methodName, BoundSql boundSql, SqlCommandType commandType) throws JSQLParserException {
|
||||
ModelTenantInfo info = cachedTenantMap.get(className);
|
||||
if (info == null || CollUtil.contains(info.getExcludeMethodNameSet(), methodName)) {
|
||||
return null;
|
||||
}
|
||||
String sql = boundSql.getSql();
|
||||
Statement statement = CCJSqlParserUtil.parse(sql);
|
||||
StringBuilder filterBuilder = new StringBuilder(64);
|
||||
filterBuilder.append(info.tableName).append(".")
|
||||
.append(info.columnName)
|
||||
.append("=")
|
||||
.append(TokenData.takeFromRequest().getTenantId());
|
||||
String dataFilter = filterBuilder.toString();
|
||||
if (commandType == SqlCommandType.UPDATE) {
|
||||
Update update = (Update) statement;
|
||||
this.buildWhereClause(update, dataFilter);
|
||||
} else if (commandType == SqlCommandType.DELETE) {
|
||||
Delete delete = (Delete) statement;
|
||||
this.buildWhereClause(delete, dataFilter);
|
||||
} else {
|
||||
Select select = (Select) statement;
|
||||
PlainSelect selectBody = (PlainSelect) select.getSelectBody();
|
||||
FromItem fromItem = selectBody.getFromItem();
|
||||
if (fromItem != null) {
|
||||
PlainSelect subSelect = null;
|
||||
if (fromItem instanceof SubSelect) {
|
||||
subSelect = (PlainSelect) ((SubSelect) fromItem).getSelectBody();
|
||||
}
|
||||
if (subSelect != null) {
|
||||
buildWhereClause(subSelect, dataFilter);
|
||||
} else {
|
||||
buildWhereClause(selectBody, dataFilter);
|
||||
}
|
||||
}
|
||||
}
|
||||
ReflectUtil.setFieldValue(boundSql, "sql", statement.toString());
|
||||
return statement;
|
||||
}
|
||||
|
||||
private void processDataPermFilter(
|
||||
String className, String methodName, BoundSql boundSql, SqlCommandType commandType, Statement statement, String sqlId)
|
||||
throws JSQLParserException {
|
||||
// 判断当前线程本地存储中,业务操作是否禁用了数据权限过滤,如果禁用,则不进行后续的数据过滤处理了。
|
||||
// 数据过滤权限中,INSERT不过滤。如果是管理员则不参与数据权限的数据过滤,显示全部数据。
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
if (Boolean.TRUE.equals(tokenData.getIsAdmin())) {
|
||||
return;
|
||||
}
|
||||
ModelDataPermInfo info = cachedDataPermMap.get(className);
|
||||
// 再次查找当前方法是否为排除方法,如果不是,就参与数据权限注入过滤。
|
||||
if (info == null || CollUtil.contains(info.getExcludeMethodNameSet(), methodName)) {
|
||||
return;
|
||||
}
|
||||
String dataPermSessionKey = RedisKeyUtil.makeSessionDataPermIdKey(tokenData.getSessionId());
|
||||
String dataPermData = redissonClient.getBucket(dataPermSessionKey).get().toString();
|
||||
if (StringUtils.isBlank(dataPermData)) {
|
||||
throw new NoDataPermException("No Related DataPerm found for SQL_ID [ " + sqlId + " ].");
|
||||
}
|
||||
Map<Integer, String> dataPermMap = new HashMap<>(8);
|
||||
for (Map.Entry<String, Object> entry : JSON.parseObject(dataPermData).entrySet()) {
|
||||
dataPermMap.put(Integer.valueOf(entry.getKey()), entry.getValue().toString());
|
||||
}
|
||||
if (MapUtils.isEmpty(dataPermMap)) {
|
||||
throw new NoDataPermException("No Related DataPerm found for SQL_ID [ " + sqlId + " ].");
|
||||
}
|
||||
if (dataPermMap.containsKey(DataPermRuleType.TYPE_ALL)) {
|
||||
return;
|
||||
}
|
||||
this.processDataPerm(info, dataPermMap, boundSql, commandType, statement);
|
||||
}
|
||||
|
||||
private void processDataPerm(
|
||||
ModelDataPermInfo info,
|
||||
Map<Integer, String> dataPermMap,
|
||||
BoundSql boundSql,
|
||||
SqlCommandType commandType,
|
||||
Statement statement) throws JSQLParserException {
|
||||
List<String> criteriaList = new LinkedList<>();
|
||||
for (Map.Entry<Integer, String> entry : dataPermMap.entrySet()) {
|
||||
String filterClause = processDataPermRule(info, entry.getKey(), entry.getValue());
|
||||
if (StringUtils.isNotBlank(filterClause)) {
|
||||
criteriaList.add(filterClause);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isEmpty(criteriaList)) {
|
||||
return;
|
||||
}
|
||||
StringBuilder filterBuilder = new StringBuilder(128);
|
||||
filterBuilder.append("(");
|
||||
filterBuilder.append(StringUtils.join(criteriaList, " OR "));
|
||||
filterBuilder.append(")");
|
||||
String dataFilter = filterBuilder.toString();
|
||||
if (statement == null) {
|
||||
String sql = boundSql.getSql();
|
||||
statement = CCJSqlParserUtil.parse(sql);
|
||||
}
|
||||
if (commandType == SqlCommandType.UPDATE) {
|
||||
Update update = (Update) statement;
|
||||
this.buildWhereClause(update, dataFilter);
|
||||
} else if (commandType == SqlCommandType.DELETE) {
|
||||
Delete delete = (Delete) statement;
|
||||
this.buildWhereClause(delete, dataFilter);
|
||||
} else {
|
||||
Select select = (Select) statement;
|
||||
PlainSelect selectBody = (PlainSelect) select.getSelectBody();
|
||||
FromItem fromItem = selectBody.getFromItem();
|
||||
PlainSelect subSelect = null;
|
||||
if (fromItem != null) {
|
||||
if (fromItem instanceof SubSelect) {
|
||||
subSelect = (PlainSelect) ((SubSelect) fromItem).getSelectBody();
|
||||
}
|
||||
if (subSelect != null) {
|
||||
buildWhereClause(subSelect, dataFilter);
|
||||
} else {
|
||||
buildWhereClause(selectBody, dataFilter);
|
||||
}
|
||||
}
|
||||
}
|
||||
ReflectUtil.setFieldValue(boundSql, "sql", statement.toString());
|
||||
}
|
||||
|
||||
private String processDataPermRule(ModelDataPermInfo info, Integer ruleType, String deptIds) {
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
StringBuilder filter = new StringBuilder(128);
|
||||
if (ruleType == DataPermRuleType.TYPE_USER_ONLY) {
|
||||
if (StringUtils.isNotBlank(info.getUserFilterColumn())) {
|
||||
if (properties.getAddTableNamePrefix()) {
|
||||
filter.append(info.getMainTableName()).append(".");
|
||||
}
|
||||
filter.append(info.getUserFilterColumn())
|
||||
.append(" = ")
|
||||
.append(tokenData.getUserId());
|
||||
}
|
||||
} else {
|
||||
if (StringUtils.isNotBlank(info.getDeptFilterColumn())) {
|
||||
if (ruleType == DataPermRuleType.TYPE_DEPT_ONLY) {
|
||||
if (properties.getAddTableNamePrefix()) {
|
||||
filter.append(info.getMainTableName()).append(".");
|
||||
}
|
||||
filter.append(info.getDeptFilterColumn())
|
||||
.append(" = ")
|
||||
.append(tokenData.getDeptId());
|
||||
} else if (ruleType == DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT) {
|
||||
filter.append(" EXISTS ")
|
||||
.append("(SELECT 1 FROM ")
|
||||
.append(properties.getDeptRelationTablePrefix())
|
||||
.append("sys_dept_relation WHERE ")
|
||||
.append(properties.getDeptRelationTablePrefix())
|
||||
.append("sys_dept_relation.parent_dept_id = ")
|
||||
.append(tokenData.getDeptId())
|
||||
.append(" AND ");
|
||||
if (properties.getAddTableNamePrefix()) {
|
||||
filter.append(info.getMainTableName()).append(".");
|
||||
}
|
||||
filter.append(info.getDeptFilterColumn())
|
||||
.append(" = ")
|
||||
.append(properties.getDeptRelationTablePrefix())
|
||||
.append("sys_dept_relation.dept_id) ");
|
||||
} else if (ruleType == DataPermRuleType.TYPE_MULTI_DEPT_AND_CHILD_DEPT) {
|
||||
filter.append(" EXISTS ")
|
||||
.append("(SELECT 1 FROM ")
|
||||
.append(properties.getDeptRelationTablePrefix())
|
||||
.append("sys_dept_relation WHERE ")
|
||||
.append(properties.getDeptRelationTablePrefix())
|
||||
.append("sys_dept_relation.parent_dept_id IN (")
|
||||
.append(deptIds)
|
||||
.append(") AND ");
|
||||
if (properties.getAddTableNamePrefix()) {
|
||||
filter.append(info.getMainTableName()).append(".");
|
||||
}
|
||||
filter.append(info.getDeptFilterColumn())
|
||||
.append(" = ")
|
||||
.append(properties.getDeptRelationTablePrefix())
|
||||
.append("sys_dept_relation.dept_id) ");
|
||||
} else if (ruleType == DataPermRuleType.TYPE_CUSTOM_DEPT_LIST) {
|
||||
if (properties.getAddTableNamePrefix()) {
|
||||
filter.append(info.getMainTableName()).append(".");
|
||||
}
|
||||
filter.append(info.getDeptFilterColumn())
|
||||
.append(" IN (")
|
||||
.append(deptIds)
|
||||
.append(") ");
|
||||
}
|
||||
}
|
||||
}
|
||||
return filter.toString();
|
||||
}
|
||||
|
||||
private void buildWhereClause(Update update, String dataFilter) throws JSQLParserException {
|
||||
if (update.getWhere() == null) {
|
||||
update.setWhere(CCJSqlParserUtil.parseCondExpression(dataFilter));
|
||||
} else {
|
||||
AndExpression and = new AndExpression(
|
||||
CCJSqlParserUtil.parseCondExpression(dataFilter), update.getWhere());
|
||||
update.setWhere(and);
|
||||
}
|
||||
}
|
||||
|
||||
private void buildWhereClause(Delete delete, String dataFilter) throws JSQLParserException {
|
||||
if (delete.getWhere() == null) {
|
||||
delete.setWhere(CCJSqlParserUtil.parseCondExpression(dataFilter));
|
||||
} else {
|
||||
AndExpression and = new AndExpression(
|
||||
CCJSqlParserUtil.parseCondExpression(dataFilter), delete.getWhere());
|
||||
delete.setWhere(and);
|
||||
}
|
||||
}
|
||||
|
||||
private void buildWhereClause(PlainSelect select, String dataFilter) throws JSQLParserException {
|
||||
if (select.getWhere() == null) {
|
||||
select.setWhere(CCJSqlParserUtil.parseCondExpression(dataFilter));
|
||||
} else {
|
||||
AndExpression and = new AndExpression(
|
||||
CCJSqlParserUtil.parseCondExpression(dataFilter), select.getWhere());
|
||||
select.setWhere(and);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object plugin(Object target) {
|
||||
return Plugin.wrap(target, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(Properties properties) {
|
||||
// 这里需要空注解,否则sonar会不happy。
|
||||
}
|
||||
|
||||
@Data
|
||||
private static final class ModelDataPermInfo {
|
||||
private Set<String> excludeMethodNameSet;
|
||||
private String userFilterColumn;
|
||||
private String deptFilterColumn;
|
||||
private String mainTableName;
|
||||
}
|
||||
|
||||
@Data
|
||||
private static final class ModelTenantInfo {
|
||||
private Set<String> excludeMethodNameSet;
|
||||
private String modelName;
|
||||
private String tableName;
|
||||
private String fieldName;
|
||||
private String columnName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.orange.demo.common.datafilter.listener;
|
||||
|
||||
import com.orange.demo.common.datafilter.interceptor.MybatisDataFilterInterceptor;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 应用服务启动监听器。
|
||||
* 目前主要功能是调用MybatisDataFilterInterceptor中的loadInfoWithDataFilter方法,
|
||||
* 将标记有过滤注解的数据加载到缓存,以提升系统运行时效率。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Component
|
||||
public class LoadDataFilterInfoListener implements ApplicationListener<ApplicationReadyEvent> {
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
|
||||
MybatisDataFilterInterceptor interceptor =
|
||||
applicationReadyEvent.getApplicationContext().getBean(MybatisDataFilterInterceptor.class);
|
||||
interceptor.loadInfoWithDataFilter();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.orange.demo.common.datafilter.config.DataFilterAutoConfig
|
||||
@@ -0,0 +1,218 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="Spring" name="Spring">
|
||||
<configuration />
|
||||
</facet>
|
||||
<facet type="web" name="Web">
|
||||
<configuration>
|
||||
<webroots />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" generated="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="common-sequence" />
|
||||
<orderEntry type="module" module-name="common-core" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.45" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.glassfish:jakarta.el:3.0.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.45" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:29.0-jre" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.checkerframework:checker-qual:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.3.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.3.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-csv:1.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.6.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.jsonwebtoken:jjwt:0.9.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.76" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.ben-manes.caffeine:caffeine:2.8.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: cn.jimmyshi:bean-query:1.1.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-all:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.30" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml:3.17" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi:3.17" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:3.17" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:2.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: stax:stax-api:1.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.virtuald:curvesapi:1.04" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: mysql:mysql-connector-java:8.0.23" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:druid-spring-boot-starter:1.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:druid:1.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-boot-starter:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-extension:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-core:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-annotation:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.2.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:3.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.kafka:spring-kafka:2.5.12.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-messaging:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.retry:spring-retry:1.2.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-freemarker:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.freemarker:freemarker:2.3.31" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:4.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-log4j2:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.13.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.13.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.13.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-jul:2.13.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.30" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.9.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-cache:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-configuration-processor:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-actuator:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-actuator-autoconfigure:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-actuator:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.micrometer:micrometer-core:1.5.13" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hdrhistogram:HdrHistogram:2.1.12" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.latencyutils:LatencyUtils:2.0.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: de.codecentric:spring-boot-admin-starter-client:2.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: de.codecentric:spring-boot-admin-client:2.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-config:2.2.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.spring:spring-context-support:1.0.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.nacos:nacos-client:1.4.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.nacos:nacos-common:1.4.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpasyncclient:4.1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore-nio:4.4.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.nacos:nacos-api:1.4.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.prometheus:simpleclient:0.5.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-commons:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-crypto:5.3.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-context:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-openfeign:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-rsa:1.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.59" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.59" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-openfeign-core:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign.form:feign-form-spring:3.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign.form:feign-form:3.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign:feign-core:10.10.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign:feign-slf4j:10.10.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign:feign-hystrix:10.10.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.netflix.archaius:archaius-core:0.7.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign:feign-httpclient:10.10.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.13" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-netflix-hystrix:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-netflix-hystrix:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-netflix-ribbon:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-netflix-archaius:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-netflix-archaius:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-configuration:commons-configuration:1.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.netflix.hystrix:hystrix-core:1.5.18" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.reactivex:rxjava:1.3.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.netflix.hystrix:hystrix-serialization:1.5.18" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: com.fasterxml.jackson.module:jackson-module-afterburner:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.netflix.hystrix:hystrix-metrics-event-stream:1.5.18" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.netflix.hystrix:hystrix-javanica:1.5.18" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.reactivex:rxjava-reactive-streams:1.2.1" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.reactivestreams:reactive-streams:1.0.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.2.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.4.1.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.4.2.Final" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mapstruct:mapstruct-processor:1.4.2.Final" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.20" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.curator:curator-recipes:4.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.curator:curator-framework:4.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.curator:curator-client:4.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.zookeeper:zookeeper:3.5.3-beta" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-cli:commons-cli:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.kafka:kafka-clients:2.4.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.luben:zstd-jni:1.4.3-1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.lz4:lz4-java:1.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.xerial.snappy:snappy-java:1.1.7.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.scala-lang:scala-library:2.12.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.lmax:disruptor:3.4.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:2.0.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:2.0.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: jakarta.xml.bind:jakarta.xml.bind-api:2.3.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: jakarta.activation:jakarta.activation-api:1.2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.16.1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest:2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter:5.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-params:5.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.vintage:junit-vintage-engine:5.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.13.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:3.3.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy:1.10.22" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.10.22" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-junit-jupiter:3.3.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.7.0" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?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>common</artifactId>
|
||||
<groupId>com.orange.demo</groupId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>common-log</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>common-log</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.orange.demo</groupId>
|
||||
<artifactId>common-sequence</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.*</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.orange.demo.common.log.annotation;
|
||||
|
||||
import com.orange.demo.common.log.model.constant.SysOperationLogType;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 操作日志记录注解。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface OperationLog {
|
||||
|
||||
/**
|
||||
* 描述。
|
||||
*/
|
||||
String description() default "";
|
||||
|
||||
/**
|
||||
* 操作类型。
|
||||
*/
|
||||
int type() default SysOperationLogType.OTHER;
|
||||
|
||||
/**
|
||||
* 是否保存应答结果。
|
||||
* 对于类似导出和文件下载之类的接口,该参与应该设置为false。
|
||||
*/
|
||||
boolean saveResponse() default true;
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
package com.orange.demo.common.log.aop;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.orange.demo.common.core.constant.ApplicationConstant;
|
||||
import com.orange.demo.common.core.object.ResponseResult;
|
||||
import com.orange.demo.common.core.object.TokenData;
|
||||
import com.orange.demo.common.core.util.ContextUtil;
|
||||
import com.orange.demo.common.core.util.IpUtil;
|
||||
import com.orange.demo.common.core.util.MyCommonUtil;
|
||||
import com.orange.demo.common.log.annotation.OperationLog;
|
||||
import com.orange.demo.common.log.config.OperationLogProperties;
|
||||
import com.orange.demo.common.log.model.SysOperationLog;
|
||||
import com.orange.demo.common.log.model.constant.SysOperationLogType;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.Signature;
|
||||
import org.aspectj.lang.annotation.*;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 操作日志记录处理AOP对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
@Order(1)
|
||||
@Slf4j
|
||||
public class OperationLogAspect {
|
||||
|
||||
@Value("${spring.application.name}")
|
||||
private String serviceName;
|
||||
@Autowired
|
||||
private KafkaTemplate<String, Object> kafkaTemplate;
|
||||
@Autowired
|
||||
private OperationLogProperties properties;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 错误信息、请求参数和应答结果字符串的最大长度。
|
||||
*/
|
||||
private final static int MAX_LENGTH = 2000;
|
||||
|
||||
/**
|
||||
* 所有controller方法。
|
||||
*/
|
||||
@Pointcut("execution(public * com.orange.demo..controller..*(..))")
|
||||
public void operationLogPointCut() {
|
||||
// 空注释,避免sonar警告
|
||||
}
|
||||
|
||||
@Around("operationLogPointCut()")
|
||||
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
// 计时。
|
||||
long start = System.currentTimeMillis();
|
||||
HttpServletRequest request = ContextUtil.getHttpRequest();
|
||||
HttpServletResponse response = ContextUtil.getHttpResponse();
|
||||
String traceId = this.getTraceId(request);
|
||||
request.setAttribute(ApplicationConstant.HTTP_HEADER_TRACE_ID, traceId);
|
||||
// 将流水号通过应答头返回给前端,便于问题精确定位。
|
||||
response.setHeader(ApplicationConstant.HTTP_HEADER_TRACE_ID, traceId);
|
||||
MDC.put(ApplicationConstant.HTTP_HEADER_TRACE_ID, traceId);
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
// 为log4j2日志设定变量,使日志可以输出更多有价值的信息。
|
||||
if (tokenData != null) {
|
||||
MDC.put("sessionId", tokenData.getSessionId());
|
||||
MDC.put("userId", tokenData.getUserId().toString());
|
||||
}
|
||||
String[] parameterNames = this.getParameterNames(joinPoint);
|
||||
Object[] args = joinPoint.getArgs();
|
||||
JSONObject jsonArgs = new JSONObject();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
Object arg = args[i];
|
||||
if (this.isNormalArgs(arg)) {
|
||||
String parameterName = parameterNames[i];
|
||||
jsonArgs.put(parameterName, arg);
|
||||
}
|
||||
}
|
||||
String params = jsonArgs.toJSONString();
|
||||
SysOperationLog operationLog = null;
|
||||
OperationLog operationLogAnnotation = null;
|
||||
boolean saveOperationLog = properties.isEnabled();
|
||||
if (saveOperationLog) {
|
||||
operationLogAnnotation = getOperationLogAnnotation(joinPoint);
|
||||
saveOperationLog = (operationLogAnnotation != null);
|
||||
}
|
||||
if (saveOperationLog) {
|
||||
operationLog = this.buildSysOperationLog(operationLogAnnotation, joinPoint, params, traceId, tokenData);
|
||||
}
|
||||
Object result;
|
||||
log.info("开始请求,url={}, reqData={}", request.getRequestURI(), params);
|
||||
try {
|
||||
// 调用原来的方法
|
||||
result = joinPoint.proceed();
|
||||
String respData = result == null ? "null" : JSON.toJSONString(result);
|
||||
Long elapse = System.currentTimeMillis() - start;
|
||||
if (saveOperationLog) {
|
||||
this.operationLogPostProcess(operationLogAnnotation, respData, operationLog, result);
|
||||
}
|
||||
log.info("请求完成, url={},elapse={}ms, respData={}", request.getRequestURI(), elapse, respData);
|
||||
} catch (Exception e) {
|
||||
if (saveOperationLog) {
|
||||
operationLog.setSuccess(false);
|
||||
operationLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, MAX_LENGTH));
|
||||
}
|
||||
log.error("请求报错,url={}, reqData={}, error={}", request.getRequestURI(), params, e.getMessage());
|
||||
throw e;
|
||||
} finally {
|
||||
if (saveOperationLog) {
|
||||
operationLog.setElapse(System.currentTimeMillis() - start);
|
||||
kafkaTemplate.send(properties.getKafkaTopic(), JSON.toJSONString(operationLog));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private SysOperationLog buildSysOperationLog(
|
||||
OperationLog operationLogAnnotation,
|
||||
ProceedingJoinPoint joinPoint,
|
||||
String params,
|
||||
String traceId,
|
||||
TokenData tokenData) {
|
||||
HttpServletRequest request = ContextUtil.getHttpRequest();
|
||||
SysOperationLog operationLog = new SysOperationLog();
|
||||
operationLog.setLogId(idGenerator.nextLongId());
|
||||
operationLog.setTraceId(traceId);
|
||||
operationLog.setDescription(operationLogAnnotation.description());
|
||||
operationLog.setOperationType(operationLogAnnotation.type());
|
||||
operationLog.setServiceName(this.serviceName);
|
||||
operationLog.setApiClass(joinPoint.getTarget().getClass().getName());
|
||||
operationLog.setApiMethod(operationLog.getApiClass() + "." + joinPoint.getSignature().getName());
|
||||
operationLog.setRequestMethod(request.getMethod());
|
||||
operationLog.setRequestUrl(request.getRequestURI());
|
||||
if (tokenData != null) {
|
||||
operationLog.setRequestIp(tokenData.getLoginIp());
|
||||
} else {
|
||||
operationLog.setRequestIp(IpUtil.getRemoteIpAddress(request));
|
||||
}
|
||||
operationLog.setOperationTime(new Date());
|
||||
if (params != null) {
|
||||
if (params.length() <= MAX_LENGTH) {
|
||||
operationLog.setRequestArguments(params);
|
||||
} else {
|
||||
operationLog.setRequestArguments(StringUtils.substring(params, 0, MAX_LENGTH));
|
||||
}
|
||||
}
|
||||
if (tokenData != null) {
|
||||
// 对于非多租户系统,该值为空可以忽略。
|
||||
operationLog.setTenantId(tokenData.getTenantId());
|
||||
operationLog.setSessionId(tokenData.getSessionId());
|
||||
operationLog.setOperatorId(tokenData.getUserId());
|
||||
operationLog.setOperatorName(tokenData.getLoginName());
|
||||
}
|
||||
return operationLog;
|
||||
}
|
||||
|
||||
private void operationLogPostProcess(
|
||||
OperationLog operationLogAnnotation, String respData, SysOperationLog operationLog, Object result) {
|
||||
if (operationLogAnnotation.saveResponse()) {
|
||||
if (respData.length() <= MAX_LENGTH) {
|
||||
operationLog.setResponseResult(respData);
|
||||
} else {
|
||||
operationLog.setResponseResult(StringUtils.substring(respData, 0, MAX_LENGTH));
|
||||
}
|
||||
}
|
||||
// 处理大部分返回ResponseResult的接口。
|
||||
if (!(result instanceof ResponseResult)) {
|
||||
if (ContextUtil.hasRequestContext()) {
|
||||
operationLog.setSuccess(ContextUtil.getHttpResponse().getStatus() == HttpServletResponse.SC_OK);
|
||||
}
|
||||
return;
|
||||
}
|
||||
ResponseResult<?> responseResult = (ResponseResult<?>) result;
|
||||
operationLog.setSuccess(responseResult.isSuccess());
|
||||
if (!responseResult.isSuccess()) {
|
||||
operationLog.setErrorMsg(responseResult.getErrorMessage());
|
||||
}
|
||||
if (operationLog.getOperationType().equals(SysOperationLogType.LOGIN)) {
|
||||
// 对于登录操作,由于在调用登录方法之前,没有可用的TokenData。
|
||||
// 因此如果登录成功,可再次通过TokenData.takeFromRequest()获取TokenData。
|
||||
if (operationLog.getSuccess()) {
|
||||
// 这里为了保证LoginController.doLogin方法,一定将TokenData存入Request.Attribute之中,
|
||||
// 我们将不做空值判断,一旦出错,开发者可在调试时立刻发现异常,并根据这里的注释进行修复。
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
// 对于非多租户系统,为了保证代码一致性,仍可保留对tenantId的赋值代码。
|
||||
operationLog.setTenantId(tokenData.getTenantId());
|
||||
operationLog.setSessionId(tokenData.getSessionId());
|
||||
operationLog.setOperatorId(tokenData.getUserId());
|
||||
operationLog.setOperatorName(tokenData.getLoginName());
|
||||
} else {
|
||||
HttpServletRequest request = ContextUtil.getHttpRequest();
|
||||
// 登录操作需要特殊处理,无论是登录成功还是失败,都要记录operator_name字段。
|
||||
operationLog.setOperatorName(request.getParameter("loginName"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String[] getParameterNames(ProceedingJoinPoint joinPoint) {
|
||||
Signature signature = joinPoint.getSignature();
|
||||
MethodSignature methodSignature = (MethodSignature) signature;
|
||||
return methodSignature.getParameterNames();
|
||||
}
|
||||
|
||||
private OperationLog getOperationLogAnnotation(JoinPoint joinPoint) throws Exception {
|
||||
Signature signature = joinPoint.getSignature();
|
||||
MethodSignature methodSignature = (MethodSignature) signature;
|
||||
Method method = methodSignature.getMethod();
|
||||
return method.getAnnotation(OperationLog.class);
|
||||
}
|
||||
|
||||
private String getTraceId(HttpServletRequest request) {
|
||||
// 获取请求流水号。
|
||||
// 对于微服务系统,为了保证traceId在全调用链的唯一性,因此在网关的过滤器中创建了该值。
|
||||
String traceId = request.getHeader(ApplicationConstant.HTTP_HEADER_TRACE_ID);
|
||||
if (StringUtils.isBlank(traceId)) {
|
||||
traceId = MyCommonUtil.generateUuid();
|
||||
}
|
||||
return traceId;
|
||||
}
|
||||
|
||||
private boolean isNormalArgs(Object o) {
|
||||
if (o instanceof List) {
|
||||
List<?> list = (List<?>) o;
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
return !(list.get(0) instanceof MultipartFile);
|
||||
}
|
||||
}
|
||||
return !(o instanceof HttpServletRequest)
|
||||
&& !(o instanceof HttpServletResponse)
|
||||
&& !(o instanceof MultipartFile);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.orange.demo.common.log.config;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
|
||||
/**
|
||||
* common-log模块的自动配置引导类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@EnableConfigurationProperties({OperationLogProperties.class})
|
||||
public class CommonLogAutoConfig {
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.orange.demo.common.log.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* 操作日志的配置类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "common-log.operation-log")
|
||||
public class OperationLogProperties {
|
||||
|
||||
/**
|
||||
* 是否采集操作日志。
|
||||
*/
|
||||
private boolean enabled = true;
|
||||
/**
|
||||
* kafka topic
|
||||
*/
|
||||
private String kafkaTopic = "SysOperationLog";
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.orange.demo.common.log.dao;
|
||||
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.log.model.SysOperationLog;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统操作日志对应的数据访问对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
public interface SysOperationLogMapper extends BaseDaoMapper<SysOperationLog> {
|
||||
|
||||
/**
|
||||
* 批量插入。
|
||||
*
|
||||
* @param operationLogList 操作日志列表。
|
||||
*/
|
||||
void insertList(List<SysOperationLog> operationLogList);
|
||||
|
||||
/**
|
||||
* 根据过滤条件和排序规则,查询操作日志。
|
||||
*
|
||||
* @param sysOperationLogFilter 操作日志的过滤对象。
|
||||
* @param orderBy 排序规则。
|
||||
* @return 查询列表。
|
||||
*/
|
||||
List<SysOperationLog> getSysOperationLogList(
|
||||
@Param("sysOperationLogFilter") SysOperationLog sysOperationLogFilter,
|
||||
@Param("orderBy") String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orange.demo.common.log.dao.SysOperationLogMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orange.demo.common.log.model.SysOperationLog">
|
||||
<id column="log_id" jdbcType="BIGINT" property="logId"/>
|
||||
<result column="description" jdbcType="VARCHAR" property="description"/>
|
||||
<result column="operation_type" jdbcType="INTEGER" property="operationType"/>
|
||||
<result column="service_name" jdbcType="VARCHAR" property="serviceName"/>
|
||||
<result column="api_class" jdbcType="VARCHAR" property="apiClass"/>
|
||||
<result column="api_method" jdbcType="VARCHAR" property="apiMethod"/>
|
||||
<result column="session_id" jdbcType="VARCHAR" property="sessionId"/>
|
||||
<result column="trace_id" jdbcType="VARCHAR" property="traceId"/>
|
||||
<result column="elapse" jdbcType="BIGINT" property="elapse"/>
|
||||
<result column="request_method" jdbcType="VARCHAR" property="requestMethod"/>
|
||||
<result column="request_url" jdbcType="VARCHAR" property="requestUrl"/>
|
||||
<result column="request_arguments" jdbcType="VARCHAR" property="requestArguments"/>
|
||||
<result column="response_result" jdbcType="VARCHAR" property="responseResult"/>
|
||||
<result column="request_ip" jdbcType="VARCHAR" property="requestIp"/>
|
||||
<result column="success" jdbcType="BIT" property="success"/>
|
||||
<result column="error_msg" jdbcType="VARCHAR" property="errorMsg"/>
|
||||
<result column="tenant_id" jdbcType="BIGINT" property="tenantId"/>
|
||||
<result column="operator_id" jdbcType="BIGINT" property="operatorId"/>
|
||||
<result column="operator_name" jdbcType="VARCHAR" property="operatorName"/>
|
||||
<result column="operation_time" jdbcType="TIMESTAMP" property="operationTime"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
||||
<sql id="filterRef">
|
||||
<if test="sysOperationLogFilter != null">
|
||||
<if test="sysOperationLogFilter.operationType != null">
|
||||
AND zz_sys_operation_log.operation_type = #{sysOperationLogFilter.operationType}
|
||||
</if>
|
||||
<if test="sysOperationLogFilter.requestUrl != null and sysOperationLogFilter.requestUrl != ''">
|
||||
<bind name = "safeRequestUrl" value = "'%' + sysOperationLogFilter.requestUrl + '%'" />
|
||||
AND zz_sys_operation_log.request_url LIKE #{safeRequestUrl}
|
||||
</if>
|
||||
<if test="sysOperationLogFilter.traceId != null and sysOperationLogFilter.traceId != ''">
|
||||
AND zz_sys_operation_log.trace_id = #{sysOperationLogFilter.traceId}
|
||||
</if>
|
||||
<if test="sysOperationLogFilter.success != null">
|
||||
AND zz_sys_operation_log.success = #{sysOperationLogFilter.success}
|
||||
</if>
|
||||
<if test="sysOperationLogFilter.operatorName != null and sysOperationLogFilter.operatorName != ''">
|
||||
<bind name = "safeOperatorName" value = "'%' + sysOperationLogFilter.operatorName + '%'" />
|
||||
AND zz_sys_operation_log.operator_name LIKE #{safeOperatorName}
|
||||
</if>
|
||||
<if test="sysOperationLogFilter.elapseMin != null and sysOperationLogFilter.elapseMin != ''">
|
||||
AND zz_sys_operation_log.elapse >= #{sysOperationLogFilter.elapseMin}
|
||||
</if>
|
||||
<if test="sysOperationLogFilter.elapseMax != null and sysOperationLogFilter.elapseMax != ''">
|
||||
AND zz_sys_operation_log.elapse <= #{sysOperationLogFilter.elapseMax}
|
||||
</if>
|
||||
<if test="sysOperationLogFilter.operationTimeStart != null and sysOperationLogFilter.operationTimeStart != ''">
|
||||
AND zz_sys_operation_log.operation_time >= #{sysOperationLogFilter.operationTimeStart}
|
||||
</if>
|
||||
<if test="sysOperationLogFilter.operationTimeEnd != null and sysOperationLogFilter.operationTimeEnd != ''">
|
||||
AND zz_sys_operation_log.operation_time <= #{sysOperationLogFilter.operationTimeEnd}
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<insert id="insertList">
|
||||
INSERT INTO zz_sys_operation_log VALUES
|
||||
<foreach collection="list" index="index" item="item" separator=",">
|
||||
(
|
||||
#{item.logId},
|
||||
#{item.description},
|
||||
#{item.operationType},
|
||||
#{item.serviceName},
|
||||
#{item.apiClass},
|
||||
#{item.apiMethod},
|
||||
#{item.sessionId},
|
||||
#{item.traceId},
|
||||
#{item.elapse},
|
||||
#{item.requestMethod},
|
||||
#{item.requestUrl},
|
||||
#{item.requestArguments},
|
||||
#{item.responseResult},
|
||||
#{item.requestIp},
|
||||
#{item.success},
|
||||
#{item.errorMsg},
|
||||
#{item.tenantId},
|
||||
#{item.operatorId},
|
||||
#{item.operatorName},
|
||||
#{item.operationTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getSysOperationLogList" resultMap="BaseResultMap" parameterType="com.orange.demo.common.log.model.SysOperationLog">
|
||||
SELECT * FROM zz_sys_operation_log
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,170 @@
|
||||
package com.orange.demo.common.log.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.orange.demo.common.core.annotation.TenantFilterColumn;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 操作日志记录表
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Data
|
||||
@TableName("zz_sys_operation_log")
|
||||
public class SysOperationLog {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@TableId(value = "log_id")
|
||||
private Long logId;
|
||||
|
||||
/**
|
||||
* 日志描述。
|
||||
*/
|
||||
@TableField(value = "description")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 操作类型。
|
||||
* 常量值定义可参考SysOperationLogType对象。
|
||||
*/
|
||||
@TableField(value = "operation_type")
|
||||
private Integer operationType;
|
||||
|
||||
/**
|
||||
* 接口所在服务名称。
|
||||
* 通常为spring.application.name配置项的值。
|
||||
*/
|
||||
@TableField(value = "service_name")
|
||||
private String serviceName;
|
||||
|
||||
/**
|
||||
* 调用的controller全类名。
|
||||
* 之所以为独立字段,是为了便于查询和统计接口的调用频度。
|
||||
*/
|
||||
@TableField(value = "api_class")
|
||||
private String apiClass;
|
||||
|
||||
/**
|
||||
* 调用的controller中的方法。
|
||||
* 格式为:接口类名 + "." + 方法名。
|
||||
*/
|
||||
@TableField(value = "api_method")
|
||||
private String apiMethod;
|
||||
|
||||
/**
|
||||
* 用户会话sessionId。
|
||||
* 主要是为了便于统计,以及跟踪查询定位问题。
|
||||
*/
|
||||
@TableField(value = "session_id")
|
||||
private String sessionId;
|
||||
|
||||
/**
|
||||
* 每次请求的Id。
|
||||
* 对于微服务之间的调用,在同一个请求的调用链中,该值是相同的。
|
||||
*/
|
||||
@TableField(value = "trace_id")
|
||||
private String traceId;
|
||||
|
||||
/**
|
||||
* 调用时长。
|
||||
*/
|
||||
@TableField(value = "elapse")
|
||||
private Long elapse;
|
||||
|
||||
/**
|
||||
* HTTP 请求方法,如GET。
|
||||
*/
|
||||
@TableField(value = "request_method")
|
||||
private String requestMethod;
|
||||
|
||||
/**
|
||||
* HTTP 请求地址。
|
||||
*/
|
||||
@TableField(value = "request_url")
|
||||
private String requestUrl;
|
||||
|
||||
/**
|
||||
* controller接口参数。
|
||||
*/
|
||||
@TableField(value = "request_arguments")
|
||||
private String requestArguments;
|
||||
|
||||
/**
|
||||
* controller应答结果。
|
||||
*/
|
||||
@TableField(value = "response_result")
|
||||
private String responseResult;
|
||||
|
||||
/**
|
||||
* 请求IP。
|
||||
*/
|
||||
@TableField(value = "request_ip")
|
||||
private String requestIp;
|
||||
|
||||
/**
|
||||
* 应答状态。
|
||||
*/
|
||||
@TableField(value = "success")
|
||||
private Boolean success;
|
||||
|
||||
/**
|
||||
* 错误信息。
|
||||
*/
|
||||
@TableField(value = "error_msg")
|
||||
private String errorMsg;
|
||||
|
||||
/**
|
||||
* 租户Id。
|
||||
* 仅用于多租户系统,是便于进行对租户的操作查询和统计分析。
|
||||
*/
|
||||
@TenantFilterColumn
|
||||
@TableField(value = "tenant_id")
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 操作员Id。
|
||||
*/
|
||||
@TableField(value = "operator_id")
|
||||
private Long operatorId;
|
||||
|
||||
/**
|
||||
* 操作员名称。
|
||||
*/
|
||||
@TableField(value = "operator_name")
|
||||
private String operatorName;
|
||||
|
||||
/**
|
||||
* 操作时间。
|
||||
*/
|
||||
@TableField(value = "operation_time")
|
||||
private Date operationTime;
|
||||
|
||||
/**
|
||||
* 调用时长最小值。
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Long elapseMin;
|
||||
|
||||
/**
|
||||
* 调用时长最大值。
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Long elapseMax;
|
||||
|
||||
/**
|
||||
* 操作开始时间。
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String operationTimeStart;
|
||||
|
||||
/**
|
||||
* 操作结束时间。
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String operationTimeEnd;
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.orange.demo.common.log.model.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 操作日志类型常量字典对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
public final class SysOperationLogType {
|
||||
|
||||
/**
|
||||
* 其他。
|
||||
*/
|
||||
public static final int OTHER = -1;
|
||||
/**
|
||||
* 登录。
|
||||
*/
|
||||
public static final int LOGIN = 0;
|
||||
/**
|
||||
* 登出。
|
||||
*/
|
||||
public static final int LOGOUT = 5;
|
||||
/**
|
||||
* 新增。
|
||||
*/
|
||||
public static final int ADD = 10;
|
||||
/**
|
||||
* 修改。
|
||||
*/
|
||||
public static final int UPDATE = 15;
|
||||
/**
|
||||
* 删除。
|
||||
*/
|
||||
public static final int DELETE = 20;
|
||||
/**
|
||||
* 新增多对多关联。
|
||||
*/
|
||||
public static final int ADD_M2M = 25;
|
||||
/**
|
||||
* 移除多对多关联。
|
||||
*/
|
||||
public static final int DELETE_M2M = 30;
|
||||
/**
|
||||
* 查询。
|
||||
*/
|
||||
public static final int LIST = 35;
|
||||
/**
|
||||
* 分组查询。
|
||||
*/
|
||||
public static final int LIST_WITH_GROUP = 40;
|
||||
/**
|
||||
* 导出。
|
||||
*/
|
||||
public static final int EXPORT = 45;
|
||||
/**
|
||||
* 上传。
|
||||
*/
|
||||
public static final int UPLOAD = 50;
|
||||
/**
|
||||
* 下载。
|
||||
*/
|
||||
public static final int DOWNLOAD = 55;
|
||||
/**
|
||||
* 重置缓存。
|
||||
*/
|
||||
public static final int RELOAD_CACHE = 60;
|
||||
/**
|
||||
* 发布。
|
||||
*/
|
||||
public static final int PUBLISH = 65;
|
||||
/**
|
||||
* 取消发布。
|
||||
*/
|
||||
public static final int UNPUBLISH = 70;
|
||||
/**
|
||||
* 暂停。
|
||||
*/
|
||||
public static final int SUSPEND = 75;
|
||||
/**
|
||||
* 恢复。
|
||||
*/
|
||||
public static final int RESUME = 80;
|
||||
/**
|
||||
* 启动流程。
|
||||
*/
|
||||
public static final int START_PROCESS = 100;
|
||||
/**
|
||||
* 停止流程。
|
||||
*/
|
||||
public static final int STOP_PROCESS = 105;
|
||||
/**
|
||||
* 删除流程。
|
||||
*/
|
||||
public static final int DELETE_PROCESS = 110;
|
||||
/**
|
||||
* 取消流程。
|
||||
*/
|
||||
public static final int CANCEL_PROCESS = 115;
|
||||
/**
|
||||
* 提交任务。
|
||||
*/
|
||||
public static final int SUBMIT_TASK = 120;
|
||||
|
||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(15);
|
||||
static {
|
||||
DICT_MAP.put(OTHER, "其他");
|
||||
DICT_MAP.put(LOGIN, "登录");
|
||||
DICT_MAP.put(LOGOUT, "登出");
|
||||
DICT_MAP.put(ADD, "新增");
|
||||
DICT_MAP.put(UPDATE, "修改");
|
||||
DICT_MAP.put(DELETE, "删除");
|
||||
DICT_MAP.put(ADD_M2M, "新增多对多关联");
|
||||
DICT_MAP.put(DELETE_M2M, "移除多对多关联");
|
||||
DICT_MAP.put(LIST, "查询");
|
||||
DICT_MAP.put(LIST_WITH_GROUP, "分组查询");
|
||||
DICT_MAP.put(EXPORT, "导出");
|
||||
DICT_MAP.put(UPLOAD, "上传");
|
||||
DICT_MAP.put(DOWNLOAD, "下载");
|
||||
DICT_MAP.put(RELOAD_CACHE, "重置缓存");
|
||||
DICT_MAP.put(PUBLISH, "发布");
|
||||
DICT_MAP.put(UNPUBLISH, "取消发布");
|
||||
DICT_MAP.put(SUSPEND, "暂停");
|
||||
DICT_MAP.put(RESUME, "恢复");
|
||||
DICT_MAP.put(START_PROCESS, "启动流程");
|
||||
DICT_MAP.put(STOP_PROCESS, "停止流程");
|
||||
DICT_MAP.put(DELETE_PROCESS, "删除流程");
|
||||
DICT_MAP.put(CANCEL_PROCESS, "取消流程");
|
||||
DICT_MAP.put(SUBMIT_TASK, "提交任务");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断参数是否为当前常量字典的合法值。
|
||||
*
|
||||
* @param value 待验证的参数值。
|
||||
* @return 合法返回true,否则false。
|
||||
*/
|
||||
public static boolean isValid(Integer value) {
|
||||
return value != null && DICT_MAP.containsKey(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私有构造函数,明确标识该常量类的作用。
|
||||
*/
|
||||
private SysOperationLogType() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.orange.demo.common.log.service;
|
||||
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
import com.orange.demo.common.log.model.SysOperationLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作日志服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
public interface SysOperationLogService extends IBaseService<SysOperationLog, Long> {
|
||||
|
||||
/**
|
||||
* 异步的插入一条新操作日志。
|
||||
*
|
||||
* @param operationLog 操作日志对象。
|
||||
*/
|
||||
void saveNewAsync(SysOperationLog operationLog);
|
||||
|
||||
/**
|
||||
* 插入一条新操作日志。
|
||||
*
|
||||
* @param operationLog 操作日志对象。
|
||||
*/
|
||||
void saveNew(SysOperationLog operationLog);
|
||||
|
||||
/**
|
||||
* 批量插入。
|
||||
*
|
||||
* @param sysOperationLogList 操作日志列表。
|
||||
*/
|
||||
void batchSave(List<SysOperationLog> sysOperationLogList);
|
||||
|
||||
/**
|
||||
* 根据过滤条件和排序规则,查询操作日志。
|
||||
*
|
||||
* @param filter 操作日志的过滤对象。
|
||||
* @param orderBy 排序规则。
|
||||
* @return 查询列表。
|
||||
*/
|
||||
List<SysOperationLog> getSysOperationLogList(SysOperationLog filter, String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.orange.demo.common.log.service.impl;
|
||||
|
||||
import com.orange.demo.common.core.annotation.MyDataSource;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.core.constant.ApplicationConstant;
|
||||
import com.orange.demo.common.log.dao.SysOperationLogMapper;
|
||||
import com.orange.demo.common.log.model.SysOperationLog;
|
||||
import com.orange.demo.common.log.service.SysOperationLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作日志服务实现类。
|
||||
* 这里需要重点解释下MyDataSource注解。在单数据源服务中,由于没有DataSourceAspect的切面类,所以该注解不会
|
||||
* 有任何作用和影响。然而在多数据源情况下,由于每个服务都有自己的DataSourceType常量对象,表示不同的数据源。
|
||||
* 而common-log在公用模块中,不能去依赖业务服务,因此这里给出了一个固定值。我们在业务的DataSourceType中,也要
|
||||
* 使用该值ApplicationConstant.OPERATION_LOG_DATASOURCE_TYPE,去关联操作日志所需的数据源配置。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@MyDataSource(ApplicationConstant.OPERATION_LOG_DATASOURCE_TYPE)
|
||||
@Service
|
||||
public class SysOperationLogServiceImpl extends BaseService<SysOperationLog, Long> implements SysOperationLogService {
|
||||
|
||||
@Autowired
|
||||
private SysOperationLogMapper sysOperationLogMapper;
|
||||
|
||||
@Override
|
||||
protected BaseDaoMapper<SysOperationLog> mapper() {
|
||||
return sysOperationLogMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步插入一条新操作日志。通常用于在橙单中创建的单体工程服务。
|
||||
*
|
||||
* @param operationLog 操作日志对象。
|
||||
*/
|
||||
@Async
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void saveNewAsync(SysOperationLog operationLog) {
|
||||
sysOperationLogMapper.insert(operationLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入一条新操作日志。
|
||||
*
|
||||
* @param operationLog 操作日志对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void saveNew(SysOperationLog operationLog) {
|
||||
sysOperationLogMapper.insert(operationLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量插入。通常用于在橙单中创建的微服务工程服务。
|
||||
*
|
||||
* @param sysOperationLogList 操作日志列表。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void batchSave(List<SysOperationLog> sysOperationLogList) {
|
||||
sysOperationLogMapper.insertList(sysOperationLogList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据过滤条件和排序规则,查询操作日志。
|
||||
*
|
||||
* @param filter 操作日志的过滤对象。
|
||||
* @param orderBy 排序规则。
|
||||
* @return 查询列表。
|
||||
*/
|
||||
@Override
|
||||
public List<SysOperationLog> getSysOperationLogList(SysOperationLog filter, String orderBy) {
|
||||
return sysOperationLogMapper.getSysOperationLogList(filter, orderBy);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.orange.demo.common.log.config.CommonLogAutoConfig
|
||||
@@ -0,0 +1,217 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="Spring" name="Spring">
|
||||
<configuration />
|
||||
</facet>
|
||||
<facet type="web" name="Web">
|
||||
<configuration>
|
||||
<webroots />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" generated="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="common-core" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.45" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.glassfish:jakarta.el:3.0.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.45" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:29.0-jre" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.checkerframework:checker-qual:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.3.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.3.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-csv:1.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.6.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.jsonwebtoken:jjwt:0.9.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.76" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.ben-manes.caffeine:caffeine:2.8.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: cn.jimmyshi:bean-query:1.1.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-all:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.30" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml:3.17" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi:3.17" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:3.17" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:2.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: stax:stax-api:1.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.virtuald:curvesapi:1.04" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: mysql:mysql-connector-java:8.0.23" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:druid-spring-boot-starter:1.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:druid:1.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-boot-starter:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-extension:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-core:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-annotation:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.2.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:3.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.xuxueli:xxl-job-core:2.2.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-all:4.1.63.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.codehaus.groovy:groovy:2.5.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-freemarker:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.freemarker:freemarker:2.3.31" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:4.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-log4j2:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.13.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.13.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.13.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-jul:2.13.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.30" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.9.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-cache:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-configuration-processor:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-actuator:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-actuator-autoconfigure:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-actuator:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.micrometer:micrometer-core:1.5.13" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hdrhistogram:HdrHistogram:2.1.12" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.latencyutils:LatencyUtils:2.0.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: de.codecentric:spring-boot-admin-starter-client:2.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: de.codecentric:spring-boot-admin-client:2.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-config:2.2.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.spring:spring-context-support:1.0.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.nacos:nacos-client:1.4.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.nacos:nacos-common:1.4.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpasyncclient:4.1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore-nio:4.4.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.nacos:nacos-api:1.4.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.prometheus:simpleclient:0.5.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-commons:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-crypto:5.3.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-context:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-openfeign:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-rsa:1.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.59" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.59" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-openfeign-core:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign.form:feign-form-spring:3.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign.form:feign-form:3.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign:feign-core:10.10.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign:feign-slf4j:10.10.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign:feign-hystrix:10.10.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.netflix.archaius:archaius-core:0.7.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign:feign-httpclient:10.10.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.13" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-netflix-hystrix:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-netflix-hystrix:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-netflix-ribbon:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-netflix-archaius:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-netflix-archaius:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-configuration:commons-configuration:1.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.netflix.hystrix:hystrix-core:1.5.18" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.reactivex:rxjava:1.3.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.netflix.hystrix:hystrix-serialization:1.5.18" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: com.fasterxml.jackson.module:jackson-module-afterburner:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.11.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.netflix.hystrix:hystrix-metrics-event-stream:1.5.18" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.netflix.hystrix:hystrix-javanica:1.5.18" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.reactivex:rxjava-reactive-streams:1.2.1" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.reactivestreams:reactive-streams:1.0.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.2.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.4.1.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.4.2.Final" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mapstruct:mapstruct-processor:1.4.2.Final" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.20" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.curator:curator-recipes:4.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.curator:curator-framework:4.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.curator:curator-client:4.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.zookeeper:zookeeper:3.5.3-beta" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-cli:commons-cli:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.kafka:kafka-clients:2.4.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.luben:zstd-jni:1.4.3-1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.lz4:lz4-java:1.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.xerial.snappy:snappy-java:1.1.7.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.scala-lang:scala-library:2.12.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.lmax:disruptor:3.4.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:2.0.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:2.0.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.3.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: jakarta.xml.bind:jakarta.xml.bind-api:2.3.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: jakarta.activation:jakarta.activation-api:1.2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.16.1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest:2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter:5.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-params:5.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.vintage:junit-vintage-engine:5.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.6.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.13.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:3.3.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy:1.10.22" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.10.22" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-junit-jupiter:3.3.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.2.14.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.7.0" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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>common</artifactId>
|
||||
<groupId>com.orange.demo</groupId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>common-xxljob</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>common-xxljob</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<xxl-job.version>2.2.0</xxl-job.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.orange.demo</groupId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xuxueli</groupId>
|
||||
<artifactId>xxl-job-core</artifactId>
|
||||
<version>${xxl-job.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.orange.demo.common.xxljob.aop;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Job处理器的AOP,目前仅仅实现了将拦截后的异常记录到本地日志服务系统,记录后重新抛给xxl-job。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
@Order(1)
|
||||
@Slf4j
|
||||
public class JobHandlerAspect {
|
||||
|
||||
@Pointcut("execution(public * com.orange.demo.*.handler..*(..))")
|
||||
public void handlerPointCut() {
|
||||
// 空注释,sonar要求的。
|
||||
}
|
||||
|
||||
@Around("handlerPointCut()")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
Class<?> clazz = point.getTarget().getClass();
|
||||
try {
|
||||
return point.proceed();
|
||||
} catch (Exception e) {
|
||||
log.error("JobHandler [" + clazz.getSimpleName() + "] throws exception.", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.orange.demo.common.xxljob.config;
|
||||
|
||||
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* xxl-job config
|
||||
*
|
||||
* @author xuxueli 2017-04-28
|
||||
*/
|
||||
@Configuration
|
||||
public class XxlJobConfig {
|
||||
private final Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
|
||||
|
||||
@Value("${xxl.job.admin.addresses}")
|
||||
private String adminAddresses;
|
||||
|
||||
@Value("${xxl.job.executor.appname}")
|
||||
private String appName;
|
||||
|
||||
@Value("${xxl.job.executor.port}")
|
||||
private int port;
|
||||
|
||||
@Value("${xxl.job.executor.logpath}")
|
||||
private String logPath;
|
||||
|
||||
@Value("${xxl.job.executor.logretentiondays}")
|
||||
private int logRetentionDays;
|
||||
|
||||
@Bean
|
||||
public XxlJobSpringExecutor xxlJobExecutor() {
|
||||
logger.info(">>>>>>>>>>> xxl-job config init.");
|
||||
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
|
||||
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
|
||||
xxlJobSpringExecutor.setAppname(appName);
|
||||
xxlJobSpringExecutor.setPort(port);
|
||||
xxlJobSpringExecutor.setLogPath(logPath);
|
||||
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
|
||||
return xxlJobSpringExecutor;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user