工程开发一段时间后,PM提出
数据脱敏
新需求;
需要加解密的字段太多、要改动的地方太多,那试试用切面处理吧。
import java.lang.annotation.*;
/**
* @author Mr.superbeyone
* @description
* @date 2023-12-22 14:32
**/
@Retention(RetentionPolicy.RUNTIME)
@Target({
ElementType.FIELD})
@Documented
public @interface XtSm4FieldAnno {
}
import java.lang.annotation.*;
/**
* @author Mr.superbeyone
* @description
* @date 2023-12-22 14:32
**/
@Retention(RetentionPolicy.RUNTIME)
@Target({
ElementType.FIELD})
@Documented
public @interface XtNotSm4FieldAnno {
}
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.*;
/**
* @author Mr.superbeyone
* @className
* @description
* @date 2023-12-22 12:43
**/
@Slf4j
@Aspect
@Order(1)
@Component
public class XtSm4Aspect {
//需要特殊处理的字段列表
private static final List<String> FIELD_LIST = Arrays.asList("idCard", "phone","idNo","customer_phone","customerPhone","id_card");
private static final String PACKAGE_PREFIX ="com.aaaaa";
@Pointcut("execution(* com.aaaaa.service..*.*(..))")
public void pointCut() {
}
@Around("pointCut()")
public