mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
cf-framework:banner、error-code移到starter-web,desensitize移除
This commit is contained in:
@@ -127,11 +127,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 业务组件 -->
|
<!-- 业务组件 -->
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-banner</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
||||||
@@ -173,11 +168,6 @@
|
|||||||
<artifactId>cf-spring-boot-starter-biz-data-permission</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-data-permission</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-biz-error-code</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-id</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-id</artifactId>
|
||||||
@@ -193,11 +183,6 @@
|
|||||||
<artifactId>cf-spring-boot-starter-captcha</artifactId>
|
<artifactId>cf-spring-boot-starter-captcha</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-desensitize</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Spring 核心 -->
|
<!-- Spring 核心 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
<?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>cf-framework</artifactId>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>cf-spring-boot-starter-banner</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<name>${project.artifactId}</name>
|
|
||||||
<description>Banner 用于在 console 控制台,打印开发文档、接口文档等</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-common</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
-6
@@ -1,6 +0,0 @@
|
|||||||
/**
|
|
||||||
* Banner 用于在 console 控制台,打印开发文档、接口文档等
|
|
||||||
*
|
|
||||||
* @author 晨丰科技
|
|
||||||
*/
|
|
||||||
package com.cf.imes.framework.banner;
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
com.cf.imes.framework.banner.config.ChenfengBannerAutoConfiguration
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
<?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>cf-framework</artifactId>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>cf-spring-boot-starter-biz-error-code</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<name>${project.artifactId}</name>
|
|
||||||
<description>
|
|
||||||
错误码 ErrorCode 的自动配置功能,提供如下功能:
|
|
||||||
1. 远程读取:项目启动时,从 system-server 服务,读取数据库中的 ErrorCode 错误码,实现错误码的提示可配置;
|
|
||||||
2. 自动更新:管理员在管理后台修数据库中的 ErrorCode 错误码时,项目自动从 system-server 服务加载最新的 ErrorCode 错误码;
|
|
||||||
3. 自动写入:项目启动时,将项目本地的错误码写到 system-server 服务中,方便管理员在管理后台编辑;
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-common</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Spring 核心 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- RPC 远程调用相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-rpc</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 业务组件 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-module-system-api</artifactId> <!-- 需要使用它,进行操作日志的记录 -->
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>jakarta.validation</groupId>
|
|
||||||
<artifactId>jakarta.validation-api</artifactId>
|
|
||||||
<scope>provided</scope> <!-- 设置为 provided,主要是 ErrorCodeProperties 使用到 -->
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
/**
|
|
||||||
* 错误码 ErrorCode 的自动配置功能,提供如下功能:
|
|
||||||
*
|
|
||||||
* 1. 远程读取:项目启动时,从 system-service 服务,读取数据库中的 ErrorCode 错误码,实现错误码的提水可配置;
|
|
||||||
* 2. 自动更新:管理员在管理后台修数据库中的 ErrorCode 错误码时,项目自动从 system-service 服务加载最新的 ErrorCode 错误码;
|
|
||||||
* 3. 自动写入:项目启动时,将项目本地的错误码写到 system-server 服务中,方便管理员在管理后台编辑;
|
|
||||||
*
|
|
||||||
* @author 晨丰科技
|
|
||||||
*/
|
|
||||||
package com.cf.imes.framework.errorcode;
|
|
||||||
-2
@@ -1,2 +0,0 @@
|
|||||||
com.cf.imes.framework.errorcode.config.ChenfengErrorCodeRpcAutoConfiguration
|
|
||||||
com.cf.imes.framework.errorcode.config.ChenfengErrorCodeAutoConfiguration
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-framework</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>cf-spring-boot-starter-desensitize</artifactId>
|
|
||||||
<description>脱敏组件:支持 JSON 返回数据时,将邮箱、手机等字段进行脱敏</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-common</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- jackson -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-annotations</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Test 测试相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-test</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.base.annotation;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.handler.DesensitizationHandler;
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.serializer.StringDesensitizeSerializer;
|
|
||||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 顶级脱敏注解,自定义注解需要使用此注解
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Target(ElementType.ANNOTATION_TYPE)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@JacksonAnnotationsInside // 此注解是其他所有 jackson 注解的元注解,打上了此注解的注解表明是 jackson 注解的一部分
|
|
||||||
@JsonSerialize(using = StringDesensitizeSerializer.class) // 指定序列化器
|
|
||||||
public @interface DesensitizeBy {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 脱敏处理器
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
Class<? extends DesensitizationHandler> handler();
|
|
||||||
|
|
||||||
}
|
|
||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.base.handler;
|
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 脱敏处理器接口
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
public interface DesensitizationHandler<T extends Annotation> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 脱敏
|
|
||||||
*
|
|
||||||
* @param origin 原始字符串
|
|
||||||
* @param annotation 注解信息
|
|
||||||
* @return 脱敏后的字符串
|
|
||||||
*/
|
|
||||||
String desensitize(String origin, T annotation);
|
|
||||||
|
|
||||||
}
|
|
||||||
-92
@@ -1,92 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.base.serializer;
|
|
||||||
|
|
||||||
import cn.hutool.core.annotation.AnnotationUtil;
|
|
||||||
import cn.hutool.core.lang.Singleton;
|
|
||||||
import cn.hutool.core.text.CharSequenceUtil;
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.annotation.DesensitizeBy;
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.handler.DesensitizationHandler;
|
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
|
||||||
import com.fasterxml.jackson.databind.BeanProperty;
|
|
||||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
|
||||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
|
||||||
import com.fasterxml.jackson.databind.ser.ContextualSerializer;
|
|
||||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.annotation.Annotation;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 脱敏序列化器
|
|
||||||
*
|
|
||||||
* 实现 JSON 返回数据时,使用 {@link DesensitizationHandler} 对声明脱敏注解的字段,进行脱敏处理。
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public class StringDesensitizeSerializer extends StdSerializer<String> implements ContextualSerializer {
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private DesensitizationHandler desensitizationHandler;
|
|
||||||
|
|
||||||
protected StringDesensitizeSerializer() {
|
|
||||||
super(String.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonSerializer<?> createContextual(SerializerProvider serializerProvider, BeanProperty beanProperty) {
|
|
||||||
DesensitizeBy annotation = beanProperty.getAnnotation(DesensitizeBy.class);
|
|
||||||
if (annotation == null) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
// 创建一个 StringDesensitizeSerializer 对象,使用 DesensitizeBy 对应的处理器
|
|
||||||
StringDesensitizeSerializer serializer = new StringDesensitizeSerializer();
|
|
||||||
serializer.setDesensitizationHandler(Singleton.get(annotation.handler()));
|
|
||||||
return serializer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void serialize(String value, JsonGenerator gen, SerializerProvider serializerProvider) throws IOException {
|
|
||||||
if (CharSequenceUtil.isBlank(value)) {
|
|
||||||
gen.writeNull();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 获取序列化字段
|
|
||||||
Field field = getField(gen);
|
|
||||||
|
|
||||||
// 自定义处理器
|
|
||||||
DesensitizeBy[] annotations = AnnotationUtil.getCombinationAnnotations(field, DesensitizeBy.class);
|
|
||||||
if (ArrayUtil.isEmpty(annotations)) {
|
|
||||||
gen.writeString(value);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (Annotation annotation : field.getAnnotations()) {
|
|
||||||
if (AnnotationUtil.hasAnnotation(annotation.annotationType(), DesensitizeBy.class)) {
|
|
||||||
value = this.desensitizationHandler.desensitize(value, annotation);
|
|
||||||
gen.writeString(value);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gen.writeString(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取字段
|
|
||||||
*
|
|
||||||
* @param generator JsonGenerator
|
|
||||||
* @return 字段
|
|
||||||
*/
|
|
||||||
private Field getField(JsonGenerator generator) {
|
|
||||||
String currentName = generator.getOutputContext().getCurrentName();
|
|
||||||
Object currentValue = generator.getCurrentValue();
|
|
||||||
Class<?> currentValueClass = currentValue.getClass();
|
|
||||||
return ReflectUtil.getField(currentValueClass, currentName);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
/**
|
|
||||||
* 脱敏组件:支持 JSON 返回数据时,将邮箱、手机等字段进行脱敏
|
|
||||||
*/
|
|
||||||
package com.cf.imes.framework.desensitize.core;
|
|
||||||
-36
@@ -1,36 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.regex.annotation;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.annotation.DesensitizeBy;
|
|
||||||
import com.cf.imes.framework.desensitize.core.regex.handler.EmailDesensitizationHandler;
|
|
||||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮箱脱敏注解
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Target({ElementType.FIELD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@JacksonAnnotationsInside
|
|
||||||
@DesensitizeBy(handler = EmailDesensitizationHandler.class)
|
|
||||||
public @interface EmailDesensitize {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 匹配的正则表达式
|
|
||||||
*/
|
|
||||||
String regex() default "(^.)[^@]*(@.*$)";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 替换规则,邮箱;
|
|
||||||
*
|
|
||||||
* 比如:example@gmail.com 脱敏之后为 e****@gmail.com
|
|
||||||
*/
|
|
||||||
String replacer() default "$1****$2";
|
|
||||||
}
|
|
||||||
-38
@@ -1,38 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.regex.annotation;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.annotation.DesensitizeBy;
|
|
||||||
import com.cf.imes.framework.desensitize.core.regex.handler.DefaultRegexDesensitizationHandler;
|
|
||||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 正则脱敏注解
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Target({ElementType.FIELD, ElementType.ANNOTATION_TYPE})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@JacksonAnnotationsInside
|
|
||||||
@DesensitizeBy(handler = DefaultRegexDesensitizationHandler.class)
|
|
||||||
public @interface RegexDesensitize {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 匹配的正则表达式(默认匹配所有)
|
|
||||||
*/
|
|
||||||
String regex() default "^[\\s\\S]*$";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 替换规则,会将匹配到的字符串全部替换成 replacer
|
|
||||||
*
|
|
||||||
* 例如:regex=123; replacer=******
|
|
||||||
* 原始字符串 123456789
|
|
||||||
* 脱敏后字符串 ******456789
|
|
||||||
*/
|
|
||||||
String replacer() default "******";
|
|
||||||
}
|
|
||||||
-38
@@ -1,38 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.regex.handler;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.handler.DesensitizationHandler;
|
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 正则表达式脱敏处理器抽象类,已实现通用的方法
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
public abstract class AbstractRegexDesensitizationHandler<T extends Annotation>
|
|
||||||
implements DesensitizationHandler<T> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String desensitize(String origin, T annotation) {
|
|
||||||
String regex = getRegex(annotation);
|
|
||||||
String replacer = getReplacer(annotation);
|
|
||||||
return origin.replaceAll(regex, replacer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取注解上的 regex 参数
|
|
||||||
*
|
|
||||||
* @param annotation 注解信息
|
|
||||||
* @return 正则表达式
|
|
||||||
*/
|
|
||||||
abstract String getRegex(T annotation);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取注解上的 replacer 参数
|
|
||||||
*
|
|
||||||
* @param annotation 注解信息
|
|
||||||
* @return 待替换的字符串
|
|
||||||
*/
|
|
||||||
abstract String getReplacer(T annotation);
|
|
||||||
|
|
||||||
}
|
|
||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.regex.handler;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.regex.annotation.RegexDesensitize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link RegexDesensitize} 的正则脱敏处理器
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
public class DefaultRegexDesensitizationHandler extends AbstractRegexDesensitizationHandler<RegexDesensitize> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String getRegex(RegexDesensitize annotation) {
|
|
||||||
return annotation.regex();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String getReplacer(RegexDesensitize annotation) {
|
|
||||||
return annotation.replacer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-22
@@ -1,22 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.regex.handler;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.regex.annotation.EmailDesensitize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link EmailDesensitize} 的脱敏处理器
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
public class EmailDesensitizationHandler extends AbstractRegexDesensitizationHandler<EmailDesensitize> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String getRegex(EmailDesensitize annotation) {
|
|
||||||
return annotation.regex();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String getReplacer(EmailDesensitize annotation) {
|
|
||||||
return annotation.replacer();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.annotation;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.annotation.DesensitizeBy;
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.handler.BankCardDesensitization;
|
|
||||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 银行卡号
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Target({ElementType.FIELD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@JacksonAnnotationsInside
|
|
||||||
@DesensitizeBy(handler = BankCardDesensitization.class)
|
|
||||||
public @interface BankCardDesensitize {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前缀保留长度
|
|
||||||
*/
|
|
||||||
int prefixKeep() default 6;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 后缀保留长度
|
|
||||||
*/
|
|
||||||
int suffixKeep() default 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 替换规则,银行卡号; 比如:9988002866797031 脱敏之后为 998800********31
|
|
||||||
*/
|
|
||||||
String replacer() default "*";
|
|
||||||
|
|
||||||
}
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.annotation;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.annotation.DesensitizeBy;
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.handler.CarLicenseDesensitization;
|
|
||||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车牌号
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Target({ElementType.FIELD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@JacksonAnnotationsInside
|
|
||||||
@DesensitizeBy(handler = CarLicenseDesensitization.class)
|
|
||||||
public @interface CarLicenseDesensitize {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前缀保留长度
|
|
||||||
*/
|
|
||||||
int prefixKeep() default 3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 后缀保留长度
|
|
||||||
*/
|
|
||||||
int suffixKeep() default 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 替换规则,车牌号;比如:粤A66666 脱敏之后为粤A6***6
|
|
||||||
*/
|
|
||||||
String replacer() default "*";
|
|
||||||
|
|
||||||
}
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.annotation;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.annotation.DesensitizeBy;
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.handler.ChineseNameDesensitization;
|
|
||||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 中文名
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Target({ElementType.FIELD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@JacksonAnnotationsInside
|
|
||||||
@DesensitizeBy(handler = ChineseNameDesensitization.class)
|
|
||||||
public @interface ChineseNameDesensitize {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前缀保留长度
|
|
||||||
*/
|
|
||||||
int prefixKeep() default 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 后缀保留长度
|
|
||||||
*/
|
|
||||||
int suffixKeep() default 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 替换规则,中文名;比如:刘子豪脱敏之后为刘**
|
|
||||||
*/
|
|
||||||
String replacer() default "*";
|
|
||||||
|
|
||||||
}
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.annotation;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.annotation.DesensitizeBy;
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.handler.FixedPhoneDesensitization;
|
|
||||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 固定电话
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Target({ElementType.FIELD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@JacksonAnnotationsInside
|
|
||||||
@DesensitizeBy(handler = FixedPhoneDesensitization.class)
|
|
||||||
public @interface FixedPhoneDesensitize {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前缀保留长度
|
|
||||||
*/
|
|
||||||
int prefixKeep() default 4;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 后缀保留长度
|
|
||||||
*/
|
|
||||||
int suffixKeep() default 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 替换规则,固定电话;比如:01086551122 脱敏之后为 0108*****22
|
|
||||||
*/
|
|
||||||
String replacer() default "*";
|
|
||||||
|
|
||||||
}
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.annotation;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.annotation.DesensitizeBy;
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.handler.IdCardDesensitization;
|
|
||||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 身份证
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Target({ElementType.FIELD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@JacksonAnnotationsInside
|
|
||||||
@DesensitizeBy(handler = IdCardDesensitization.class)
|
|
||||||
public @interface IdCardDesensitize {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前缀保留长度
|
|
||||||
*/
|
|
||||||
int prefixKeep() default 6;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 后缀保留长度
|
|
||||||
*/
|
|
||||||
int suffixKeep() default 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 替换规则,身份证号码;比如:530321199204074611 脱敏之后为 530321**********11
|
|
||||||
*/
|
|
||||||
String replacer() default "*";
|
|
||||||
|
|
||||||
}
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.annotation;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.annotation.DesensitizeBy;
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.handler.MobileDesensitization;
|
|
||||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 手机号
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Target({ElementType.FIELD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@JacksonAnnotationsInside
|
|
||||||
@DesensitizeBy(handler = MobileDesensitization.class)
|
|
||||||
public @interface MobileDesensitize {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前缀保留长度
|
|
||||||
*/
|
|
||||||
int prefixKeep() default 3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 后缀保留长度
|
|
||||||
*/
|
|
||||||
int suffixKeep() default 4;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 替换规则,手机号;比如:13248765917 脱敏之后为 132****5917
|
|
||||||
*/
|
|
||||||
String replacer() default "*";
|
|
||||||
|
|
||||||
}
|
|
||||||
-42
@@ -1,42 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.annotation;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.annotation.DesensitizeBy;
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.handler.PasswordDesensitization;
|
|
||||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Target({ElementType.FIELD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@JacksonAnnotationsInside
|
|
||||||
@DesensitizeBy(handler = PasswordDesensitization.class)
|
|
||||||
public @interface PasswordDesensitize {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前缀保留长度
|
|
||||||
*/
|
|
||||||
int prefixKeep() default 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 后缀保留长度
|
|
||||||
*/
|
|
||||||
int suffixKeep() default 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 替换规则,密码;
|
|
||||||
*
|
|
||||||
* 比如:123456 脱敏之后为 ******
|
|
||||||
*/
|
|
||||||
String replacer() default "*";
|
|
||||||
|
|
||||||
}
|
|
||||||
-43
@@ -1,43 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.annotation;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.annotation.DesensitizeBy;
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.handler.DefaultDesensitizationHandler;
|
|
||||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 滑动脱敏注解
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Target({ElementType.FIELD, ElementType.ANNOTATION_TYPE})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@JacksonAnnotationsInside
|
|
||||||
@DesensitizeBy(handler = DefaultDesensitizationHandler.class)
|
|
||||||
public @interface SliderDesensitize {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 后缀保留长度
|
|
||||||
*/
|
|
||||||
int suffixKeep() default 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 替换规则,会将前缀后缀保留后,全部替换成 replacer
|
|
||||||
*
|
|
||||||
* 例如:prefixKeep = 1; suffixKeep = 2; replacer = "*";
|
|
||||||
* 原始字符串 123456
|
|
||||||
* 脱敏后 1***56
|
|
||||||
*/
|
|
||||||
String replacer() default "*";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前缀保留长度
|
|
||||||
*/
|
|
||||||
int prefixKeep() default 0;
|
|
||||||
}
|
|
||||||
-78
@@ -1,78 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.handler;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.handler.DesensitizationHandler;
|
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 滑动脱敏处理器抽象类,已实现通用的方法
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
public abstract class AbstractDesensitizationHandler<T extends Annotation>
|
|
||||||
implements DesensitizationHandler<T> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String desensitize(String origin, T annotation) {
|
|
||||||
int prefixKeep = getPrefixKeep(annotation);
|
|
||||||
int suffixKeep = getSuffixKeep(annotation);
|
|
||||||
String replacer = getReplacer(annotation);
|
|
||||||
int length = origin.length();
|
|
||||||
|
|
||||||
// 情况一:原始字符串长度小于等于保留长度,则原始字符串全部替换
|
|
||||||
if (prefixKeep >= length || suffixKeep >= length) {
|
|
||||||
return buildReplacerByLength(replacer, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 情况二:原始字符串长度小于等于前后缀保留字符串长度,则原始字符串全部替换
|
|
||||||
if ((prefixKeep + suffixKeep) >= length) {
|
|
||||||
return buildReplacerByLength(replacer, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 情况三:原始字符串长度大于前后缀保留字符串长度,则替换中间字符串
|
|
||||||
int interval = length - prefixKeep - suffixKeep;
|
|
||||||
return origin.substring(0, prefixKeep) +
|
|
||||||
buildReplacerByLength(replacer, interval) +
|
|
||||||
origin.substring(prefixKeep + interval);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据长度循环构建替换符
|
|
||||||
*
|
|
||||||
* @param replacer 替换符
|
|
||||||
* @param length 长度
|
|
||||||
* @return 构建后的替换符
|
|
||||||
*/
|
|
||||||
private String buildReplacerByLength(String replacer, int length) {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
for (int i = 0; i < length; i++) {
|
|
||||||
builder.append(replacer);
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前缀保留长度
|
|
||||||
*
|
|
||||||
* @param annotation 注解信息
|
|
||||||
* @return 前缀保留长度
|
|
||||||
*/
|
|
||||||
abstract Integer getPrefixKeep(T annotation);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 后缀保留长度
|
|
||||||
*
|
|
||||||
* @param annotation 注解信息
|
|
||||||
* @return 后缀保留长度
|
|
||||||
*/
|
|
||||||
abstract Integer getSuffixKeep(T annotation);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 替换符
|
|
||||||
*
|
|
||||||
* @param annotation 注解信息
|
|
||||||
* @return 替换符
|
|
||||||
*/
|
|
||||||
abstract String getReplacer(T annotation);
|
|
||||||
|
|
||||||
}
|
|
||||||
-78
@@ -1,78 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.handler;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.handler.DesensitizationHandler;
|
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 滑动脱敏处理器抽象类,已实现通用的方法
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
public abstract class AbstractSliderDesensitizationHandler<T extends Annotation>
|
|
||||||
implements DesensitizationHandler<T> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String desensitize(String origin, T annotation) {
|
|
||||||
int prefixKeep = getPrefixKeep(annotation);
|
|
||||||
int suffixKeep = getSuffixKeep(annotation);
|
|
||||||
String replacer = getReplacer(annotation);
|
|
||||||
int length = origin.length();
|
|
||||||
|
|
||||||
// 情况一:原始字符串长度小于等于保留长度,则原始字符串全部替换
|
|
||||||
if (prefixKeep >= length || suffixKeep >= length) {
|
|
||||||
return buildReplacerByLength(replacer, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 情况二:原始字符串长度小于等于前后缀保留字符串长度,则原始字符串全部替换
|
|
||||||
if ((prefixKeep + suffixKeep) >= length) {
|
|
||||||
return buildReplacerByLength(replacer, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 情况三:原始字符串长度大于前后缀保留字符串长度,则替换中间字符串
|
|
||||||
int interval = length - prefixKeep - suffixKeep;
|
|
||||||
return origin.substring(0, prefixKeep) +
|
|
||||||
buildReplacerByLength(replacer, interval) +
|
|
||||||
origin.substring(prefixKeep + interval);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据长度循环构建替换符
|
|
||||||
*
|
|
||||||
* @param replacer 替换符
|
|
||||||
* @param length 长度
|
|
||||||
* @return 构建后的替换符
|
|
||||||
*/
|
|
||||||
private String buildReplacerByLength(String replacer, int length) {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
for (int i = 0; i < length; i++) {
|
|
||||||
builder.append(replacer);
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前缀保留长度
|
|
||||||
*
|
|
||||||
* @param annotation 注解信息
|
|
||||||
* @return 前缀保留长度
|
|
||||||
*/
|
|
||||||
abstract Integer getPrefixKeep(T annotation);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 后缀保留长度
|
|
||||||
*
|
|
||||||
* @param annotation 注解信息
|
|
||||||
* @return 后缀保留长度
|
|
||||||
*/
|
|
||||||
abstract Integer getSuffixKeep(T annotation);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 替换符
|
|
||||||
*
|
|
||||||
* @param annotation 注解信息
|
|
||||||
* @return 替换符
|
|
||||||
*/
|
|
||||||
abstract String getReplacer(T annotation);
|
|
||||||
|
|
||||||
}
|
|
||||||
-27
@@ -1,27 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.handler;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.annotation.BankCardDesensitize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link BankCardDesensitize} 的脱敏处理器
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
public class BankCardDesensitization extends AbstractSliderDesensitizationHandler<BankCardDesensitize> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
Integer getPrefixKeep(BankCardDesensitize annotation) {
|
|
||||||
return annotation.prefixKeep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
Integer getSuffixKeep(BankCardDesensitize annotation) {
|
|
||||||
return annotation.suffixKeep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String getReplacer(BankCardDesensitize annotation) {
|
|
||||||
return annotation.replacer();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-25
@@ -1,25 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.handler;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.annotation.CarLicenseDesensitize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link CarLicenseDesensitize} 的脱敏处理器
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
public class CarLicenseDesensitization extends AbstractSliderDesensitizationHandler<CarLicenseDesensitize> {
|
|
||||||
@Override
|
|
||||||
Integer getPrefixKeep(CarLicenseDesensitize annotation) {
|
|
||||||
return annotation.prefixKeep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
Integer getSuffixKeep(CarLicenseDesensitize annotation) {
|
|
||||||
return annotation.suffixKeep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String getReplacer(CarLicenseDesensitize annotation) {
|
|
||||||
return annotation.replacer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-27
@@ -1,27 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.handler;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.annotation.ChineseNameDesensitize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link ChineseNameDesensitize} 的脱敏处理器
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
public class ChineseNameDesensitization extends AbstractSliderDesensitizationHandler<ChineseNameDesensitize> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
Integer getPrefixKeep(ChineseNameDesensitize annotation) {
|
|
||||||
return annotation.prefixKeep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
Integer getSuffixKeep(ChineseNameDesensitize annotation) {
|
|
||||||
return annotation.suffixKeep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String getReplacer(ChineseNameDesensitize annotation) {
|
|
||||||
return annotation.replacer();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-25
@@ -1,25 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.handler;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.annotation.SliderDesensitize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link SliderDesensitize} 的脱敏处理器
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
public class DefaultDesensitizationHandler extends AbstractSliderDesensitizationHandler<SliderDesensitize> {
|
|
||||||
@Override
|
|
||||||
Integer getPrefixKeep(SliderDesensitize annotation) {
|
|
||||||
return annotation.prefixKeep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
Integer getSuffixKeep(SliderDesensitize annotation) {
|
|
||||||
return annotation.suffixKeep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String getReplacer(SliderDesensitize annotation) {
|
|
||||||
return annotation.replacer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-25
@@ -1,25 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.handler;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.annotation.FixedPhoneDesensitize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link FixedPhoneDesensitize} 的脱敏处理器
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
public class FixedPhoneDesensitization extends AbstractSliderDesensitizationHandler<FixedPhoneDesensitize> {
|
|
||||||
@Override
|
|
||||||
Integer getPrefixKeep(FixedPhoneDesensitize annotation) {
|
|
||||||
return annotation.prefixKeep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
Integer getSuffixKeep(FixedPhoneDesensitize annotation) {
|
|
||||||
return annotation.suffixKeep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String getReplacer(FixedPhoneDesensitize annotation) {
|
|
||||||
return annotation.replacer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-25
@@ -1,25 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.handler;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.annotation.IdCardDesensitize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link IdCardDesensitize} 的脱敏处理器
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
public class IdCardDesensitization extends AbstractSliderDesensitizationHandler<IdCardDesensitize> {
|
|
||||||
@Override
|
|
||||||
Integer getPrefixKeep(IdCardDesensitize annotation) {
|
|
||||||
return annotation.prefixKeep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
Integer getSuffixKeep(IdCardDesensitize annotation) {
|
|
||||||
return annotation.suffixKeep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String getReplacer(IdCardDesensitize annotation) {
|
|
||||||
return annotation.replacer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-26
@@ -1,26 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.handler;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.annotation.MobileDesensitize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link MobileDesensitize} 的脱敏处理器
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
public class MobileDesensitization extends AbstractSliderDesensitizationHandler<MobileDesensitize> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
Integer getPrefixKeep(MobileDesensitize annotation) {
|
|
||||||
return annotation.prefixKeep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
Integer getSuffixKeep(MobileDesensitize annotation) {
|
|
||||||
return annotation.suffixKeep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String getReplacer(MobileDesensitize annotation) {
|
|
||||||
return annotation.replacer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-25
@@ -1,25 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.slider.handler;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.annotation.PasswordDesensitize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link PasswordDesensitize} 的码脱敏处理器
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
public class PasswordDesensitization extends AbstractSliderDesensitizationHandler<PasswordDesensitize> {
|
|
||||||
@Override
|
|
||||||
Integer getPrefixKeep(PasswordDesensitize annotation) {
|
|
||||||
return annotation.prefixKeep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
Integer getSuffixKeep(PasswordDesensitize annotation) {
|
|
||||||
return annotation.suffixKeep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String getReplacer(PasswordDesensitize annotation) {
|
|
||||||
return annotation.replacer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-98
@@ -1,98 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
|
||||||
import com.cf.imes.framework.desensitize.core.regex.annotation.EmailDesensitize;
|
|
||||||
import com.cf.imes.framework.desensitize.core.regex.annotation.RegexDesensitize;
|
|
||||||
import com.cf.imes.framework.desensitize.core.annotation.Address;
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.annotation.BankCardDesensitize;
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.annotation.CarLicenseDesensitize;
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.annotation.ChineseNameDesensitize;
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.annotation.FixedPhoneDesensitize;
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.annotation.IdCardDesensitize;
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.annotation.PasswordDesensitize;
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.annotation.MobileDesensitize;
|
|
||||||
import com.cf.imes.framework.desensitize.core.slider.annotation.SliderDesensitize;
|
|
||||||
import com.cf.imes.framework.test.core.ut.BaseMockitoUnitTest;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link DesensitizeTest} 的单元测试
|
|
||||||
*/
|
|
||||||
public class DesensitizeTest extends BaseMockitoUnitTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
// 准备参数
|
|
||||||
DesensitizeDemo desensitizeDemo = new DesensitizeDemo();
|
|
||||||
desensitizeDemo.setNickname("晨丰科技");
|
|
||||||
desensitizeDemo.setBankCard("9988002866797031");
|
|
||||||
desensitizeDemo.setCarLicense("粤A66666");
|
|
||||||
desensitizeDemo.setFixedPhone("01086551122");
|
|
||||||
desensitizeDemo.setIdCard("530321199204074611");
|
|
||||||
desensitizeDemo.setPassword("123456");
|
|
||||||
desensitizeDemo.setPhoneNumber("13248765917");
|
|
||||||
desensitizeDemo.setSlider1("ABCDEFG");
|
|
||||||
desensitizeDemo.setSlider2("ABCDEFG");
|
|
||||||
desensitizeDemo.setSlider3("ABCDEFG");
|
|
||||||
desensitizeDemo.setEmail("1@email.com");
|
|
||||||
desensitizeDemo.setRegex("你好,我是晨丰科技");
|
|
||||||
desensitizeDemo.setAddress("北京市海淀区上地十街10号");
|
|
||||||
desensitizeDemo.setOrigin("晨丰科技");
|
|
||||||
|
|
||||||
// 调用
|
|
||||||
DesensitizeDemo d = JsonUtils.parseObject(JsonUtils.toJsonString(desensitizeDemo), DesensitizeDemo.class);
|
|
||||||
// 断言
|
|
||||||
assertNotNull(d);
|
|
||||||
assertEquals("芋***", d.getNickname());
|
|
||||||
assertEquals("998800********31", d.getBankCard());
|
|
||||||
assertEquals("粤A6***6", d.getCarLicense());
|
|
||||||
assertEquals("0108*****22", d.getFixedPhone());
|
|
||||||
assertEquals("530321**********11", d.getIdCard());
|
|
||||||
assertEquals("******", d.getPassword());
|
|
||||||
assertEquals("132****5917", d.getPhoneNumber());
|
|
||||||
assertEquals("#######", d.getSlider1());
|
|
||||||
assertEquals("ABC*EFG", d.getSlider2());
|
|
||||||
assertEquals("*******", d.getSlider3());
|
|
||||||
assertEquals("1****@email.com", d.getEmail());
|
|
||||||
assertEquals("你好,我是*", d.getRegex());
|
|
||||||
assertEquals("北京市海淀区上地十街10号*", d.getAddress());
|
|
||||||
assertEquals("晨丰科技", d.getOrigin());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class DesensitizeDemo {
|
|
||||||
|
|
||||||
@ChineseNameDesensitize
|
|
||||||
private String nickname;
|
|
||||||
@BankCardDesensitize
|
|
||||||
private String bankCard;
|
|
||||||
@CarLicenseDesensitize
|
|
||||||
private String carLicense;
|
|
||||||
@FixedPhoneDesensitize
|
|
||||||
private String fixedPhone;
|
|
||||||
@IdCardDesensitize
|
|
||||||
private String idCard;
|
|
||||||
@PasswordDesensitize
|
|
||||||
private String password;
|
|
||||||
@MobileDesensitize
|
|
||||||
private String phoneNumber;
|
|
||||||
@SliderDesensitize(prefixKeep = 6, suffixKeep = 1, replacer = "#")
|
|
||||||
private String slider1;
|
|
||||||
@SliderDesensitize(prefixKeep = 3, suffixKeep = 3)
|
|
||||||
private String slider2;
|
|
||||||
@SliderDesensitize(prefixKeep = 10)
|
|
||||||
private String slider3;
|
|
||||||
@EmailDesensitize
|
|
||||||
private String email;
|
|
||||||
@RegexDesensitize(regex = "晨丰科技", replacer = "*")
|
|
||||||
private String regex;
|
|
||||||
@Address
|
|
||||||
private String address;
|
|
||||||
private String origin;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-30
@@ -1,30 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.annotation;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.DesensitizeTest;
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.annotation.DesensitizeBy;
|
|
||||||
import com.cf.imes.framework.desensitize.core.handler.AddressHandler;
|
|
||||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 地址
|
|
||||||
*
|
|
||||||
* 用于 {@link DesensitizeTest} 测试使用
|
|
||||||
*
|
|
||||||
* @author gaibu
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Target({ElementType.FIELD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@JacksonAnnotationsInside
|
|
||||||
@DesensitizeBy(handler = AddressHandler.class)
|
|
||||||
public @interface Address {
|
|
||||||
|
|
||||||
String replacer() default "*";
|
|
||||||
|
|
||||||
}
|
|
||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
package com.cf.imes.framework.desensitize.core.handler;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.desensitize.core.DesensitizeTest;
|
|
||||||
import com.cf.imes.framework.desensitize.core.base.handler.DesensitizationHandler;
|
|
||||||
import com.cf.imes.framework.desensitize.core.annotation.Address;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link Address} 的脱敏处理器
|
|
||||||
*
|
|
||||||
* 用于 {@link DesensitizeTest} 测试使用
|
|
||||||
*/
|
|
||||||
public class AddressHandler implements DesensitizationHandler<Address> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String desensitize(String origin, Address annotation) {
|
|
||||||
return origin + annotation.replacer();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -67,6 +67,12 @@
|
|||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cf.imes</groupId>
|
||||||
|
<artifactId>cf-module-system-api</artifactId> <!-- 需要使用它,进行错误码的记录 -->
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId> <!-- 多数据源 -->
|
<artifactId>dynamic-datasource-spring-boot-starter</artifactId> <!-- 多数据源 -->
|
||||||
|
|||||||
+3
@@ -4,3 +4,6 @@ com.cf.imes.framework.swagger.config.ChenfengSwaggerAutoConfiguration
|
|||||||
com.cf.imes.framework.web.config.ChenfengWebAutoConfiguration
|
com.cf.imes.framework.web.config.ChenfengWebAutoConfiguration
|
||||||
com.cf.imes.framework.apilog.config.ChenfengApiLogRpcAutoConfiguration
|
com.cf.imes.framework.apilog.config.ChenfengApiLogRpcAutoConfiguration
|
||||||
com.cf.imes.framework.async.ChenfengAsyncAutoConfiguration
|
com.cf.imes.framework.async.ChenfengAsyncAutoConfiguration
|
||||||
|
com.cf.imes.framework.banner.config.ChenfengBannerAutoConfiguration
|
||||||
|
com.cf.imes.framework.errorcode.config.ChenfengErrorCodeRpcAutoConfiguration
|
||||||
|
com.cf.imes.framework.errorcode.config.ChenfengErrorCodeAutoConfiguration
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>cf-common</module>
|
<module>cf-common</module>
|
||||||
<module>cf-spring-boot-starter-env</module>
|
<module>cf-spring-boot-starter-env</module>
|
||||||
<module>cf-spring-boot-starter-banner</module>
|
|
||||||
<module>cf-spring-boot-starter-mybatis</module>
|
<module>cf-spring-boot-starter-mybatis</module>
|
||||||
<module>cf-spring-boot-starter-redis</module>
|
<module>cf-spring-boot-starter-redis</module>
|
||||||
<module>cf-spring-boot-starter-web</module>
|
<module>cf-spring-boot-starter-web</module>
|
||||||
@@ -36,14 +35,12 @@
|
|||||||
<module>cf-spring-boot-starter-biz-pay</module>
|
<module>cf-spring-boot-starter-biz-pay</module>
|
||||||
<module>cf-spring-boot-starter-biz-organ</module>
|
<module>cf-spring-boot-starter-biz-organ</module>
|
||||||
<module>cf-spring-boot-starter-biz-data-permission</module>
|
<module>cf-spring-boot-starter-biz-data-permission</module>
|
||||||
<module>cf-spring-boot-starter-biz-error-code</module>
|
|
||||||
<module>cf-spring-boot-starter-biz-id</module>
|
<module>cf-spring-boot-starter-biz-id</module>
|
||||||
<module>cf-spring-boot-starter-biz-ip</module>
|
<module>cf-spring-boot-starter-biz-ip</module>
|
||||||
|
|
||||||
<module>cf-spring-boot-starter-flowable</module>
|
<module>cf-spring-boot-starter-flowable</module>
|
||||||
<module>cf-spring-boot-starter-captcha</module>
|
<module>cf-spring-boot-starter-captcha</module>
|
||||||
<module>cf-spring-boot-starter-websocket</module>
|
<module>cf-spring-boot-starter-websocket</module>
|
||||||
<module>cf-spring-boot-starter-desensitize</module>
|
|
||||||
<module>cf-spring-boot-starter-elasticsearch</module>
|
<module>cf-spring-boot-starter-elasticsearch</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|||||||
@@ -22,16 +22,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 业务组件 -->
|
<!-- 业务组件 -->
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-banner</artifactId>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.springdoc</groupId>
|
|
||||||
<artifactId>springdoc-openapi-webmvc-core</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-module-system-api</artifactId>
|
<artifactId>cf-module-system-api</artifactId>
|
||||||
@@ -112,10 +102,6 @@
|
|||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-module-system-api</artifactId>
|
<artifactId>cf-module-system-api</artifactId>
|
||||||
</include>
|
</include>
|
||||||
<include>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-banner</artifactId>
|
|
||||||
</include>
|
|
||||||
<include>
|
<include>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-monitor</artifactId>
|
<artifactId>cf-spring-boot-starter-monitor</artifactId>
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.cf.imes.gateway.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目启动成功后,提供文档相关的地址
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class BannerApplicationRunner implements ApplicationRunner {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) {
|
||||||
|
ThreadUtil.execute(() -> {
|
||||||
|
ThreadUtil.sleep(1, TimeUnit.SECONDS); // 延迟 1 秒,保证输出到结尾
|
||||||
|
log.info("\n----------------------------------------------------------\n\t" +
|
||||||
|
"晨丰IMES项目启动成功!\n" +
|
||||||
|
"----------------------------------------------------------"
|
||||||
|
);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
晨丰科技 http://www.cf.com
|
||||||
|
Application Version: ${chenfeng.info.version}
|
||||||
|
Spring Boot Version: ${spring-boot.version}
|
||||||
|
|
||||||
|
.__ __. ______ .______ __ __ _______
|
||||||
|
| \ | | / __ \ | _ \ | | | | / _____|
|
||||||
|
| \| | | | | | | |_) | | | | | | | __
|
||||||
|
| . ` | | | | | | _ < | | | | | | |_ |
|
||||||
|
| |\ | | `--' | | |_) | | `--' | | |__| |
|
||||||
|
|__| \__| \______/ |______/ \______/ \______|
|
||||||
|
|
||||||
|
███╗ ██╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗
|
||||||
|
████╗ ██║██╔═══██╗ ██╔══██╗██║ ██║██╔════╝
|
||||||
|
██╔██╗ ██║██║ ██║ ██████╔╝██║ ██║██║ ███╗
|
||||||
|
██║╚██╗██║██║ ██║ ██╔══██╗██║ ██║██║ ██║
|
||||||
|
██║ ╚████║╚██████╔╝ ██████╔╝╚██████╔╝╚██████╔╝
|
||||||
|
╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝
|
||||||
@@ -38,10 +38,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 业务组件 -->
|
<!-- 业务组件 -->
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-banner</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
||||||
@@ -50,10 +46,6 @@
|
|||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-organ</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-organ</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-biz-error-code</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Web 相关 -->
|
<!-- Web 相关 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -176,14 +168,6 @@
|
|||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-module-system-api</artifactId>
|
<artifactId>cf-module-system-api</artifactId>
|
||||||
</include>
|
</include>
|
||||||
<include>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-banner</artifactId>
|
|
||||||
</include>
|
|
||||||
<include>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-biz-error-code</artifactId>
|
|
||||||
</include>
|
|
||||||
<include>
|
<include>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
||||||
|
|||||||
@@ -29,10 +29,6 @@
|
|||||||
<artifactId>cf-spring-boot-starter-biz-dict</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-dict</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- 业务组件 -->
|
<!-- 业务组件 -->
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-banner</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
||||||
@@ -41,10 +37,6 @@
|
|||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-organ</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-organ</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-biz-error-code</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- Web 相关 -->
|
<!-- Web 相关 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
@@ -224,10 +216,6 @@
|
|||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-module-system-api</artifactId>
|
<artifactId>cf-module-system-api</artifactId>
|
||||||
</include>
|
</include>
|
||||||
<include>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-banner</artifactId>
|
|
||||||
</include>
|
|
||||||
<include>
|
<include>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-data-permission</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-data-permission</artifactId>
|
||||||
@@ -236,10 +224,6 @@
|
|||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-dict</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-dict</artifactId>
|
||||||
</include>
|
</include>
|
||||||
<include>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-biz-error-code</artifactId>
|
|
||||||
</include>
|
|
||||||
<include>
|
<include>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
||||||
|
|||||||
@@ -36,10 +36,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 业务组件 -->
|
<!-- 业务组件 -->
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-banner</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
||||||
@@ -48,10 +44,6 @@
|
|||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-organ</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-organ</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-biz-error-code</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Web 相关 -->
|
<!-- Web 相关 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -187,14 +179,6 @@
|
|||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-module-system-api</artifactId>
|
<artifactId>cf-module-system-api</artifactId>
|
||||||
</include>
|
</include>
|
||||||
<include>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-banner</artifactId>
|
|
||||||
</include>
|
|
||||||
<include>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-biz-error-code</artifactId>
|
|
||||||
</include>
|
|
||||||
<include>
|
<include>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
||||||
@@ -277,8 +261,6 @@
|
|||||||
cf-module-infra-api,
|
cf-module-infra-api,
|
||||||
cf-module-prod-plan-api,
|
cf-module-prod-plan-api,
|
||||||
cf-module-system-api,
|
cf-module-system-api,
|
||||||
cf-spring-boot-starter-banner,
|
|
||||||
cf-spring-boot-starter-biz-error-code,
|
|
||||||
cf-spring-boot-starter-biz-operatelog,
|
cf-spring-boot-starter-biz-operatelog,
|
||||||
cf-spring-boot-starter-excel,
|
cf-spring-boot-starter-excel,
|
||||||
cf-spring-boot-starter-monitor,
|
cf-spring-boot-starter-monitor,
|
||||||
|
|||||||
@@ -42,10 +42,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 业务组件 -->
|
<!-- 业务组件 -->
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-banner</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
||||||
@@ -202,10 +198,6 @@
|
|||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-module-system-api</artifactId>
|
<artifactId>cf-module-system-api</artifactId>
|
||||||
</include>
|
</include>
|
||||||
<include>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-banner</artifactId>
|
|
||||||
</include>
|
|
||||||
<include>
|
<include>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
||||||
|
|||||||
@@ -42,10 +42,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 业务组件 -->
|
<!-- 业务组件 -->
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-banner</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-operatelog</artifactId>
|
||||||
@@ -62,10 +58,6 @@
|
|||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-organ</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-organ</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-biz-error-code</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-ip</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-ip</artifactId>
|
||||||
@@ -255,18 +247,10 @@
|
|||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-module-system-api</artifactId>
|
<artifactId>cf-module-system-api</artifactId>
|
||||||
</include>
|
</include>
|
||||||
<include>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-banner</artifactId>
|
|
||||||
</include>
|
|
||||||
<include>
|
<include>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-dict</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-dict</artifactId>
|
||||||
</include>
|
</include>
|
||||||
<include>
|
|
||||||
<groupId>com.cf.imes</groupId>
|
|
||||||
<artifactId>cf-spring-boot-starter-biz-error-code</artifactId>
|
|
||||||
</include>
|
|
||||||
<include>
|
<include>
|
||||||
<groupId>com.cf.imes</groupId>
|
<groupId>com.cf.imes</groupId>
|
||||||
<artifactId>cf-spring-boot-starter-biz-ip</artifactId>
|
<artifactId>cf-spring-boot-starter-biz-ip</artifactId>
|
||||||
|
|||||||
Reference in New Issue
Block a user