package net.vtstar.zhongtong.avi.global.interceptor;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.context.annotation.Configuration;

@Configuration
@Aspect
public class PageAspect {


    //@Pointcut("execution(* net.vtstar.huaying.mes..*.controller.*.*(..))")
    public void pointCut() {
    }

    /**
     * 前置通知
     */
    //@Around("pointCut()")
    public Object proceed(ProceedingJoinPoint joinPoint) throws Throwable {

        String[] argNames = ((MethodSignature)joinPoint.getSignature()).getParameterNames();
        Object[] args = joinPoint.getArgs();
        for (int i = 0; i <argNames.length ; i++) {
            String argName=argNames[i];
            if(argName.equals("pageNum")&&args[i]!=null){
                if(Integer.valueOf(args[i].toString())<0){
                    args[i]=0;
                }
            }
            if(argName.equals("pageSize")&&args[i]!=null){
                if(Integer.valueOf(args[i].toString())<0){
                    args[i]=20;
                }
            }
        }
        return joinPoint.proceed(args);
    }







}

