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