fix 修复 获取 SensitiveService 空问题 增加空兼容

2.X
疯狂的狮子li 3 years ago
parent 58b8446416
commit c4f7c32605

@ -1,5 +1,6 @@
package com.ruoyi.common.core.jackson; package com.ruoyi.common.core.jackson;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.BeanProperty; import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonMappingException;
@ -26,7 +27,7 @@ public class SensitiveJsonSerializer extends JsonSerializer<String> implements C
@Override @Override
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException { public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
SensitiveService sensitiveService = SpringUtils.getBean(SensitiveService.class); SensitiveService sensitiveService = SpringUtils.getBean(SensitiveService.class);
if (sensitiveService.isSensitive()) { if (ObjectUtil.isNotNull(sensitiveService) && sensitiveService.isSensitive()) {
gen.writeString(strategy.desensitizer().apply(value)); gen.writeString(strategy.desensitizer().apply(value));
} else { } else {
gen.writeString(value); gen.writeString(value);

Loading…
Cancel
Save