@Aspect
@Component
public class TimeAspect {
/**
* 切入Controller
*/
@Pointcut("execution(public * com.yf.game.app.controller.GameRecordController.submitGameRecord(..))")
public void execService() {
}
@Around("execService()")
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
boolean canJoin = false;
Date nowTime = new Date();
canJoin = activeTimeLimits.canJoinActive(nowTime);
if(!canJoin) {
throw new TimeLimitException(parseResult(nowTime));
}
Object result = pjp.proceed();
return result;
}
/**
* 组装结果
* @param targetTime
* @return
*/
private ApiRest