package com.xintong.visualinspection.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import org.springframework.validation.BindingResult;

import com.xintong.system.err.BusinessException;
import com.xintong.visualinspection.controller.BaseController;
@Aspect
@Component
public class ControllerValidatorInterceptor {
	 @Around("execution(* com.xintong.visualinspection.controller..*.*(..)) && args(..,bindingResult)")
     public Object doAround(ProceedingJoinPoint pjp, BindingResult bindingResult) throws Throwable {
         Object retVal;
         if (bindingResult.hasErrors()) {
             throw new BusinessException(20001,BaseController.getValidatorErrors(bindingResult));
         } else {
             retVal = pjp.proceed();
         }
         return retVal;
     }
}
