Browse Source

alteams 上线版本 2022年10月26日 sxm

master
[li_she] 3 years ago
parent
commit
d714b9deb3
  1. 33
      src/main/java/com/alteams/common/aop/RepeatSubmitAspect.java
  2. 2
      src/main/java/com/alteams/modules/shoporder/service/impl/OrderTimeHistServiceImpl.java

33
src/main/java/com/alteams/common/aop/RepeatSubmitAspect.java

@ -1,11 +1,9 @@
package com.alteams.common.aop; package com.alteams.common.aop;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alteams.common.exception.XJException;
import com.alteams.modules.sys.entity.SysUserEntity; import com.alteams.modules.sys.entity.SysUserEntity;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
@ -16,27 +14,28 @@ import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.TimeUnit;
/** /**
* @author LR
* @version V1.0
* @ClassName: RepeatSubmitAspect * @ClassName: RepeatSubmitAspect
* @Description: 自定义注释切点 * @Description: 自定义注释切点
* @author LR
* @date 2020年4月17日 * @date 2020年4月17日
* @version V1.0
*/ */
@Component @Component
@Aspect @Aspect
public class RepeatSubmitAspect { public class RepeatSubmitAspect {
//缓存数据存放
//缓存数据存放 后续要改小时间 目前十秒钟
private static final Cache<String, Object> caches = CacheBuilder.newBuilder() private static final Cache<String, Object> caches = CacheBuilder.newBuilder()
.maximumSize(10000).expireAfterWrite(10, TimeUnit.SECONDS).build();
.maximumSize(10000).expireAfterWrite(5, TimeUnit.SECONDS).build();
//切点 //切点
@Pointcut("@annotation(com.alteams.common.annotation.RepeatSubmit)") @Pointcut("@annotation(com.alteams.common.annotation.RepeatSubmit)")
public void pointCut() {}
public void pointCut() {
}
//处理业务逻辑 //处理业务逻辑
@Around("pointCut()") @Around("pointCut()")
@ -48,9 +47,7 @@ public class RepeatSubmitAspect {
SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
//判断是否是否null //判断是否是否null
if (null == currentUser) { if (null == currentUser) {
HttpServletResponse response = attributes.getResponse();
response.sendError(HttpServletResponse.SC_FORBIDDEN, "Session is expired!");
return response;
throw new XJException("Session is expired!", 500);
} }
String username = currentUser.getUsername(); String username = currentUser.getUsername();
//根据用户id+url作为唯一识别的请求 //根据用户id+url作为唯一识别的请求
@ -61,16 +58,14 @@ public class RepeatSubmitAspect {
if (caches.getIfPresent(key) == null) { if (caches.getIfPresent(key) == null) {
caches.put(key, key); caches.put(key, key);
} else { } else {
HttpServletResponse response = attributes.getResponse();
response.sendError(500, "重复提交!");
return response;
throw new XJException("重复提交!", 500);
} }
} }
//通过检验继续操作 //通过检验继续操作
try { try {
return pjp.proceed(); return pjp.proceed();
} catch (Throwable e) { } catch (Throwable e) {
throw new RuntimeException(e.getMessage());
throw new XJException(e.getMessage());
} }
} }
} }

2
src/main/java/com/alteams/modules/shoporder/service/impl/OrderTimeHistServiceImpl.java

@ -313,8 +313,6 @@ public class OrderTimeHistServiceImpl extends ServiceImpl<OrderTimeHistDao, Orde
} }
public OrderTimeHistEntity getTotalOrderTimeHist(OrderTimeHistEntity orderTimeHistQuery) { public OrderTimeHistEntity getTotalOrderTimeHist(OrderTimeHistEntity orderTimeHistQuery) {
return this.baseMapper.getTotalOrderTimeHist(orderTimeHistQuery); return this.baseMapper.getTotalOrderTimeHist(orderTimeHistQuery);
} }

Loading…
Cancel
Save