package com.jpsoft.shinestar.advice;

import lombok.extern.slf4j.Slf4j;
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;

@Slf4j
@Aspect
@Component
public class DAOAdvice {
    @Pointcut("(execution(public * com.jpsoft.shinestar..dao.*.*(..)))")
    public void pointcut(){

    }

    @Around("pointcut()")
    public Object around(ProceedingJoinPoint point) throws Throwable {
        Object obj = null;

        try {
            obj = point.proceed();
        }
        catch (Exception ex){
            log.error(ex.getMessage(),ex);
            throw new RuntimeException("数据库错误!");
        }

        return obj;
    }
}
