测试用户
2023-04-13 43393f2bb11cbf9e6af40077bbc5284660e8a754
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.common.aspect;
 
import com.common.core.utils.DesensitiveUtils;
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.stereotype.Component;
 
/**
 * @description: 定义切面来处理敏感数据接口
 * @author: duanyashu
 * @time: 2021-03-10 14:16
 */
@Aspect
@Component
public class DesensitiveAspect {
 
    @Pointcut("@annotation(com.common.annotation.DesensitiveApi) || @within(com.common.annotation.DesensitiveApi)")
    public void operation(){}
 
 
    @Around("operation()")
    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
        Object obj = joinPoint.proceed();
        if (obj != null && !DesensitiveUtils.isPrimitive(obj.getClass())) {
            //进行脱敏处理
            DesensitiveUtils.format(obj);
        }
        return  obj;
    }
}