|
|
|
@ -10,10 +10,12 @@ 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.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.web.context.request.RequestContextHolder; |
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes; |
|
|
|
|
|
|
|
import javax.annotation.PostConstruct; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
@ -29,9 +31,21 @@ import java.util.concurrent.TimeUnit; |
|
|
|
@Aspect |
|
|
|
public class RepeatSubmitAspect { |
|
|
|
|
|
|
|
@Value("${repeatSubmit.time}") |
|
|
|
private int repeatSubmitTime; |
|
|
|
|
|
|
|
|
|
|
|
// 缓存数据存放,后续可调整缓存过期时间 |
|
|
|
private static Cache<String, Object> caches; |
|
|
|
|
|
|
|
//缓存数据存放 后续要改小时间 目前十秒钟 |
|
|
|
private static final Cache<String, Object> caches = CacheBuilder.newBuilder() |
|
|
|
.maximumSize(10000).expireAfterWrite(10, TimeUnit.SECONDS).build(); |
|
|
|
@PostConstruct |
|
|
|
public void init() { |
|
|
|
caches = CacheBuilder.newBuilder() |
|
|
|
.maximumSize(10000) |
|
|
|
.expireAfterWrite(repeatSubmitTime, TimeUnit.SECONDS) |
|
|
|
.build(); |
|
|
|
} |
|
|
|
|
|
|
|
//切点 |
|
|
|
@Pointcut("@annotation(com.gaotao.common.annotation.RepeatSubmit)") |
|
|
|
|