12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package com.vcarecity.publish.aop;
-
- import com.vcarecity.publish.api.ApiResult;
- import com.vcarecity.publish.controller.PrepareController;
- 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;
-
- /**
- * @author VcKerry on 12/20/19
- */
-
- @Aspect
- @Component
- public class PrepareAopController {
-
-
- @Pointcut("execution(public * com.vcarecity.publish.controller.*.*(..))")
- public void preparePointcut() {
-
- }
-
-
- @Around("preparePointcut()")
- public Object check(ProceedingJoinPoint pjp) throws Throwable {
- Object target = pjp.getTarget();
-
- if (target instanceof PrepareController) {
-
- if (((PrepareController) target).isPrepare()) {
- return pjp.proceed();
- }
- // 数据没有准备好...
- return ApiResult.builder().status(40000).message("data loading ").build();
- }
-
- return pjp.proceed();
- }
-
- }
|