UNPKG

create-base-teek-theme

Version:

``` npm create base-teek-theme@latest my-first-blog ```

71 lines (53 loc) 1.4 kB
--- date: 2025-03-28 05:10:11 title: 数据脱敏 permalink: /pages/c54241 tags: - Spring Boot author: name: 华总 link: https://xiaoying.org.cn categories: - 后端 - 功能扩展 - 通用模块 --- ## 添加注解脱敏 在字段上加上`@Desensitization`注解及对应的类型即可脱敏 ```java @Data public class Person { @Desensitization(type = DesensitizationTypeEnum.PHONE) private String phone; @Desensitization(type = DesensitizationTypeEnum.MY_RULE, startInclude = 3, endExclude = 7) private String customPhone; @Desensitization(type = DesensitizationTypeEnum.EMAIL) private String email; } ``` 所有类型如下 ```java MY_RULE //可自定义脱敏的位置 USER_ID //用户id CHINESE_NAME //中文姓名 ID_CARD // 身份证号 FIXED_PHONE //座机号码 PHONE //手机号码 ADDRESS //地址 EMAIL //电子邮件 PASSWORD //密码 CAR_LICENSE //中国大陆车牌,包含普通车辆、新能源车辆 BANK_CARD //银行卡号 ``` ## 使用 ```java @PostMapping("/") public Person testDesensitization(){ Person person = new Person(); person.setPhone("12345678901"); person.setCustomPhone("12345678901"); person.setEmail("12345678901@qq.com"); System.out.println(person); return person; } ```