perf: 优化脱敏工具,修复父类中脱敏注解无效的bug
This commit is contained in:
@@ -102,7 +102,9 @@ public class TestController {
|
||||
@TokenIgnore
|
||||
public ApiResp<List<TestFile>> desensitize() {
|
||||
TestFile file = new TestFile("11111");
|
||||
file.setTest("111111");
|
||||
TestFile file1 = new TestFile("22222");
|
||||
file1.setTest("22222");
|
||||
return ApiResp.respOK(CollUtil.newArrayList(file, file1));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,21 @@
|
||||
package com.tiesheng.demo.pojos;
|
||||
|
||||
import com.tiesheng.annotation.desensitize.Desensitize;
|
||||
import com.tiesheng.poi.pojos.PoiWriteBase;
|
||||
|
||||
public class TestFile implements PoiWriteBase {
|
||||
|
||||
public class TestFile extends TestParent implements PoiWriteBase {
|
||||
|
||||
@Desensitize()
|
||||
private String test;
|
||||
private String name;
|
||||
|
||||
public TestFile(String test) {
|
||||
this.test = test;
|
||||
public TestFile(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter、getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getTest() {
|
||||
return test;
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setTest(String test) {
|
||||
this.test = test;
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.tiesheng.demo.pojos;
|
||||
|
||||
import com.tiesheng.annotation.desensitize.Desensitize;
|
||||
import com.tiesheng.poi.pojos.PoiWriteBase;
|
||||
|
||||
|
||||
public class TestParent implements PoiWriteBase {
|
||||
|
||||
private String id;
|
||||
|
||||
@Desensitize()
|
||||
private String test;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter、getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTest() {
|
||||
return test;
|
||||
}
|
||||
|
||||
public void setTest(String test) {
|
||||
this.test = test;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.tiesheng.util;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
||||
import com.tiesheng.util.config.desensitize.DesensitizeValueFilter;
|
||||
import com.tiesheng.util.config.DesensitizeValueFilter;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.tiesheng.util.config.desensitize;
|
||||
package com.tiesheng.util.config;
|
||||
|
||||
import cn.hutool.core.util.ClassUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.serializer.ValueFilter;
|
||||
import com.tiesheng.annotation.desensitize.Desensitize;
|
||||
@@ -21,7 +21,7 @@ public class DesensitizeValueFilter implements ValueFilter {
|
||||
return value;
|
||||
}
|
||||
|
||||
Field field = ClassUtil.getDeclaredField(object.getClass(), name);
|
||||
Field field = ReflectUtil.getField(object.getClass(), name);
|
||||
if (ObjectUtil.isEmpty(field)) {
|
||||
return value;
|
||||
}
|
||||
Reference in New Issue
Block a user