package com.tzy.aop;

import com.tzy.common.utils.bean.SensitiveDataUtils;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * 敏感数据处理切面
 */
@Aspect
@Component
public class SensitiveDataAspect {

    @Pointcut("@annotation(com.tzy.common.annotation.SensitiveData)")
    public void sensitiveDataPointcut() {
    }

    @AfterReturning(pointcut = "sensitiveDataPointcut()", returning = "result")
    public void handleSensitiveData(Object result) {
        if (result != null) {
            SensitiveDataUtils.handleSensitiveData(result);
        }
    }
}
