基于实体的注解
先定义一个基于对象的脱敏注解
/**
* 属性脱敏注解
*
* @author kandw [kandw@yinhai.com]
* @version 2019/8/28
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface TaSensitive {
/**
* 返回脱敏字段是否带加密文本,若是设置为true,则和返回脱敏文本时同时返回本字段的RSA加密字段
*
* @return
*/
boolean withEncrypt() default false;
/**
* 前缀预留位数
* 比如:
* prefixLength=3
* private String idCard="41234560987123543"
* 打码后为: idCard= 412**************
*/
int prefixLength() default 0;
/**
* 后缀预留位数
* 比如:
* suffixLength=3
* private String idCard="41234560987123543"
* 打码后为: idCard= **************543
*/
int suffixLength() default 0;</