/**
* Created by 12274 on 2018/8/29.
* 实现类所有方法入参校验
*/
@Aspect
@Component
@Slf4j
public class AopServiceImplConfig {
@Pointcut("execution(public * cn.primeledger.bitun.boss.biz.api.*.*(..))")
public void paramValidate(){
}
@Before("paramValidate()")
public void before(JoinPoint joinPoint) throws Throwable {
//参数数组 不可能为空,如果没有参数->{},如果参数为null->{null}
Object[] paramArray = joinPoint.getArgs();
log.info("class={},methon name={},methon param={}",joinPoint.getSignature().getName(),paramArray);
//判断参数数组是否为null
if (paramArray != null && paramArray.length > 0){
try{
for (Object obj : paramArray) {
BeanValidator.validate(obj).failThrow();
}
}catch (Exception e){
throw new BossParamsException(e.getMessage());
}
}
}
}