| | |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.io.IoUtil; |
| | | import cn.hutool.core.lang.Validator; |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.filter.RepeatedlyRequestWrapper; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.RedisUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.config.properties.RepeatSubmitProperties; |
| | | import com.ruoyi.framework.config.properties.TokenProperties; |
| | | import com.ruoyi.common.properties.TokenProperties; |
| | | import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | |
| | | private final TokenProperties tokenProperties; |
| | | private final RepeatSubmitProperties repeatSubmitProperties; |
| | | private final RedisCache redisCache; |
| | | |
| | | |
| | | @SuppressWarnings("unchecked") |
| | |
| | | } |
| | | |
| | | // body参数为空,获取Parameter的数据 |
| | | if (Validator.isEmpty(nowParams)) { |
| | | if (StringUtils.isEmpty(nowParams)) { |
| | | nowParams = JsonUtils.toJsonString(request.getParameterMap()); |
| | | } |
| | | Map<String, Object> nowDataMap = new HashMap<String, Object>(); |
| | |
| | | |
| | | // 唯一值(没有消息头则使用请求地址) |
| | | String submitKey = request.getHeader(tokenProperties.getHeader()); |
| | | if (Validator.isEmpty(submitKey)) { |
| | | if (StringUtils.isEmpty(submitKey)) { |
| | | submitKey = url; |
| | | } |
| | | |
| | | // 唯一标识(指定key + 消息头) |
| | | String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + submitKey; |
| | | |
| | | Object sessionObj = redisCache.getCacheObject(cacheRepeatKey); |
| | | Object sessionObj = RedisUtils.getCacheObject(cacheRepeatKey); |
| | | if (sessionObj != null) { |
| | | Map<String, Object> sessionMap = (Map<String, Object>) sessionObj; |
| | | if (sessionMap.containsKey(url)) { |
| | |
| | | } |
| | | Map<String, Object> cacheMap = new HashMap<String, Object>(); |
| | | cacheMap.put(url, nowDataMap); |
| | | redisCache.setCacheObject(cacheRepeatKey, cacheMap, Convert.toInt(intervalTime), TimeUnit.MILLISECONDS); |
| | | RedisUtils.setCacheObject(cacheRepeatKey, cacheMap, Convert.toInt(intervalTime), TimeUnit.MILLISECONDS); |
| | | return false; |
| | | } |
| | | |