elastic-data-test

PrepareAopController.java 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package com.vcarecity.publish.aop;
  2. import com.vcarecity.publish.api.ApiResult;
  3. import com.vcarecity.publish.controller.PrepareController;
  4. import org.aspectj.lang.ProceedingJoinPoint;
  5. import org.aspectj.lang.annotation.Around;
  6. import org.aspectj.lang.annotation.Aspect;
  7. import org.aspectj.lang.annotation.Pointcut;
  8. import org.springframework.stereotype.Component;
  9. /**
  10. * @author VcKerry on 12/20/19
  11. */
  12. @Aspect
  13. @Component
  14. public class PrepareAopController {
  15. @Pointcut("execution(public * com.vcarecity.publish.controller.*.*(..))")
  16. public void preparePointcut() {
  17. }
  18. @Around("preparePointcut()")
  19. public Object check(ProceedingJoinPoint pjp) throws Throwable {
  20. Object target = pjp.getTarget();
  21. if (target instanceof PrepareController) {
  22. if (((PrepareController) target).isPrepare()) {
  23. return pjp.proceed();
  24. }
  25. // 数据没有准备好...
  26. return ApiResult.builder().status(40000).message("data loading ").build();
  27. }
  28. return pjp.proceed();
  29. }
  30. }