package com.zhouyu.sensitive;
import cn.hutool.core.util.DesensitizedUtil;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.ContextualSerializer;
import java.io.IOException;
public class SensitiveInfoSerialize extends JsonSerializer<String> implements ContextualSerializer {
private DesensitizedUtil.DesensitizedType desensitizedType;
@Override
public void serialize(String s, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, IOException {
jsonGenerator.writeString(DesensitizedUtil.desensitized(s, desensitizedType));
}
@Override
public JsonSerializer<?> createContextual(SerializerProvider serializerProvider, BeanProperty beanProperty) throws JsonMappingException {
Sensitive annotation = beanProperty.getAnnotation(Sensitive.class);
if (annotation != null) {
this.desensitizedType = annotation.value();
return this;
}
return serializerProvider.findValueSerializer(beanProperty.getType(), beanProperty);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
自定义注解结合Hutool对SpringBoot接口返回数据进行脱敏 自定义注解结合Hutool对SpringBoot接口返回数据进行脱敏 自定义注解结合Hutool对SpringBoot接口返回数据进行脱敏 自定义注解结合Hutool对SpringBoot接口返回数据进行脱敏 自定义注解结合Hutool对SpringBoot接口返回数据进行脱敏 自定义注解结合Hutool对SpringBoot接口返回数据进行脱敏 自定义注解结合Hutool对SpringBoot接口返回数据进行脱敏 自定义注解结合Hutool对SpringBoot接口返回数据进行脱敏 自定义注解结合Hutool对SpringBoot接口返回数据进行脱敏 自定义注解结合Hutool对SpringBoot接口返回数据进行脱敏 自定义注解结合Hutool对SpringBoot接口返回数据进行脱敏 自定义注解结合Hutool对SpringBoot接口返回数据进行脱敏 自定义注解结合Hutool对SpringBoot接口返回数据进行脱敏 自定义注解结合Hutool对SpringBoot接口返回数据进行脱敏 自定义注解结合Hut
资源推荐
资源详情
资源评论
收起资源包目录
springbootdemo12312.zip (24个子文件)
SpringBoot3Demo
pom.xml 2KB
src
test
java
main
resources
application.properties 29B
java
com
zhouyu
sensitive
SensitiveInfoSerialize.java 1KB
Sensitive.java 608B
ZhouyuService.java 335B
MyApplication.java 355B
ZhouyuController.java 455B
User.java 379B
.idea
jarRepositories.xml 1KB
uiDesigner.xml 9KB
jpa-buddy.xml 192B
workspace.xml 11KB
misc.xml 628B
inspectionProfiles
Project_Default.xml 271B
compiler.xml 791B
.gitignore 184B
encodings.xml 267B
target
classes
application.properties 29B
com
zhouyu
sensitive
SensitiveInfoSerialize.class 3KB
Sensitive.class 801B
User.class 3KB
ZhouyuController.class 811B
ZhouyuService.class 707B
MyApplication.class 715B
generated-sources
annotations
共 24 条
- 1
资源评论
飞翔的佩奇
- 粉丝: 3552
- 资源: 799
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功