update 格式化代码结构 统一编码格式

This commit is contained in:
phanes
2022-01-16 16:51:23 +08:00
committed by 疯狂的狮子Li
parent 3fef2b68dc
commit 868942e202
74 changed files with 203 additions and 226 deletions

View File

@ -16,6 +16,7 @@ import java.util.Objects;
/**
* 数据脱敏json序列化工具
*
* @author Yjoioooo
*/
public class SensitiveJsonSerializer extends JsonSerializer<String> implements ContextualSerializer {
@ -25,7 +26,7 @@ public class SensitiveJsonSerializer extends JsonSerializer<String> implements C
@Override
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
SensitiveService sensitiveService = SpringUtils.getBean(SensitiveService.class);
if (sensitiveService.isSensitive()){
if (sensitiveService.isSensitive()) {
gen.writeString(value);
} else {
gen.writeString(strategy.desensitizer().apply(value));
@ -36,7 +37,7 @@ public class SensitiveJsonSerializer extends JsonSerializer<String> implements C
@Override
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException {
Sensitive annotation = property.getAnnotation(Sensitive.class);
if (Objects.nonNull(annotation)&&Objects.equals(String.class, property.getType().getRawClass())) {
if (Objects.nonNull(annotation) && Objects.equals(String.class, property.getType().getRawClass())) {
this.strategy = annotation.strategy();
return this;
}