本文主要是介绍Java日志脱敏框架Sensitive对手机号码脱敏处理,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
效果图:
pom.xml
<dependency><groupId>com.github.houbb</groupId><artifactId>sensitive-core</artifactId><version>0.0.9</version>
</dependency>
xxxInfoDTO
import com.github.houbb.sensitive.annotation.Sensitive;
import com.github.houbb.sensitive.core.api.strategory.StrategyPhone;@Excel(name = "联系方式")@ApiModelProperty(value = "联系方式")// 手机号脱敏处理@Sensitive(strategy = StrategyPhone.class)private String phone;// 其他类型@Sensitive(strategy = StrategyChineseName.class)@Sensitive(strategy = StrategyCardId.class)@Sensitive(strategy = StrategyPassword.class)@Sensitive(strategy = StrategyEmail.class)// 如果某个属性是单个集合或者对象,则需要使用注解 @SensitiveEntry@SensitiveEntry@Sensitive(strategy = StrategyChineseName.class)private List<String> chineseNameList;@SensitiveEntry@Sensitive(strategy = StrategyChineseName.class)private String[] chineseNameArray;
Controller
脱敏 = SensitiveUtil.desCopyCollection(数据);
@GetMapping(value = "/getxxxList")@ApiOperation(value = "获取列表", notes = "列表")@LogOperation(value = "获取列表")public Result<List<xxxInfoDTO>> getxxxInfo(@ApiIgnore @RequestParam Map<String, Object> param){List<xxxInfoDTO> data = SensitiveUtil.desCopyCollection(xxxService.list(param));return new Result<List<xxxInfoDTO>>().ok(data);}
这篇关于Java日志脱敏框架Sensitive对手机号码脱敏处理的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!