package ink.wgink.database.aop;

import ink.wgink.exceptions.base.SystemException;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import java.sql.SQLException;

/**
 * @ClassName: JdbcAop
 * @Description: jdbcAop
 * @Author: wanggeng
 * @Date: 2021/10/29 11:10 上午
 * @Version: 1.0
 */
@Aspect
@Component
public class JdbcAop {

    @Around("execution(public * ink.wgink.database.service..*.*(..))")
    public Object apiLogAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        try {
            return proceedingJoinPoint.proceed();
        } catch (Throwable e) {
            if (e instanceof SQLException) {
                throw new SystemException(e.getMessage());
            }
            throw e;
        }
    }

}
