Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf3b88b43b | ||
|
|
0a98e81109 | ||
|
|
e3c051d443 | ||
|
|
282a46458a | ||
|
|
637a9d1ace |
20
pom.xml
20
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>springboot-parent</name>
|
||||
<description>杭州铁晟科技有限公司基础依赖</description>
|
||||
@@ -57,55 +57,55 @@
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-database</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-login</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-web</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-util</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-message</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-encrypt</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-ademo</artifactId>
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.tiesheng.demo.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import com.tiesheng.annotation.token.TokenIgnore;
|
||||
import com.tiesheng.demo.pojos.TestFile;
|
||||
import com.tiesheng.login.config.token.TsTokenConfig;
|
||||
import com.tiesheng.login.config.token.bean.TokenBean;
|
||||
import com.tiesheng.message.config.aliyun.AliyunSmsConfig;
|
||||
@@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
@@ -92,4 +95,13 @@ public class TestController {
|
||||
return ApiResp.respOK(search);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("desensitize")
|
||||
@TokenIgnore
|
||||
public ApiResp<List<TestFile>> desensitize() {
|
||||
TestFile file = new TestFile("11111");
|
||||
TestFile file1 = new TestFile("22222");
|
||||
return ApiResp.respOK(CollUtil.newArrayList(file, file1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
//package com.tiesheng.demo.pojos;
|
||||
//
|
||||
//import com.alibaba.excel.annotation.ExcelProperty;
|
||||
//import com.tiesheng.poi.pojos.PoiWriteBase;
|
||||
//
|
||||
//public class TestFile implements PoiWriteBase {
|
||||
//
|
||||
//
|
||||
// @ExcelProperty("测试")
|
||||
// private String test;
|
||||
//
|
||||
// public TestFile(String test) {
|
||||
// this.test = test;
|
||||
// }
|
||||
//
|
||||
// ///////////////////////////////////////////////////////////////////////////
|
||||
// // setter、getter
|
||||
// ///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// public String getTest() {
|
||||
// return test;
|
||||
// }
|
||||
//
|
||||
// public void setTest(String test) {
|
||||
// this.test = test;
|
||||
// }
|
||||
//}
|
||||
package com.tiesheng.demo.pojos;
|
||||
|
||||
import com.tiesheng.annotation.desensitize.Desensitize;
|
||||
import com.tiesheng.poi.pojos.PoiWriteBase;
|
||||
|
||||
public class TestFile implements PoiWriteBase {
|
||||
|
||||
|
||||
@Desensitize()
|
||||
private String test;
|
||||
|
||||
public TestFile(String test) {
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter、getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getTest() {
|
||||
return test;
|
||||
}
|
||||
|
||||
public void setTest(String test) {
|
||||
this.test = test;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.tiesheng.annotation.desensitize;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Desensitize {
|
||||
|
||||
int prefix() default 1;
|
||||
|
||||
int suffix() default 1;
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-database</artifactId>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.tiesheng.database.service;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@Component
|
||||
public interface DbDataInitializer {
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
void init();
|
||||
|
||||
}
|
||||
@@ -35,12 +35,17 @@ public class DbMigrationInitializer implements ServletContextInitializer {
|
||||
DataSource dataSource;
|
||||
@Autowired
|
||||
DbMigrationConfig dbMigrationConfig;
|
||||
@Autowired(required = false)
|
||||
List<DbDataInitializer> dbDataInitializerList;
|
||||
|
||||
|
||||
@Override
|
||||
public void onStartup(ServletContext servletContext) {
|
||||
try {
|
||||
startDeal();
|
||||
if (dbDataInitializerList != null) {
|
||||
dbDataInitializerList.forEach(DbDataInitializer::init);
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-encrypt</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-login</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-message</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-util</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.6.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-web</artifactId>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.tiesheng.core.config.desensitize;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.serializer.ValueFilter;
|
||||
import com.tiesheng.annotation.desensitize.Desensitize;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class ValueDesensitizeFilter implements ValueFilter {
|
||||
|
||||
@Override
|
||||
public Object process(Object object, String name, Object value) {
|
||||
if (ObjectUtil.isEmpty(value) || !(value instanceof String)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
try {
|
||||
Field field = object.getClass().getDeclaredField(name);
|
||||
Desensitize desensitize = field.getAnnotation(Desensitize.class);
|
||||
if (String.class != field.getType() || ObjectUtil.isEmpty(desensitize)) {
|
||||
return value;
|
||||
}
|
||||
String originVal = String.valueOf(value);
|
||||
return StrUtil.hide(originVal, desensitize.prefix(), StrUtil.length(originVal) - desensitize.suffix());
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.tiesheng.core.config.json;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
||||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
||||
import com.tiesheng.core.config.desensitize.ValueDesensitizeFilter;
|
||||
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -30,6 +31,7 @@ public class FastJsonMessageConverter {
|
||||
SerializerFeature.WriteNullStringAsEmpty,
|
||||
SerializerFeature.WriteEnumUsingName);
|
||||
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
config.setSerializeFilters(new ValueDesensitizeFilter());
|
||||
|
||||
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
|
||||
fastConverter.setFastJsonConfig(config);
|
||||
|
||||
Reference in New Issue
Block a user