update 同步ruoyi修改命名
This commit is contained in:
parent
76bf987203
commit
40984e201e
@ -109,7 +109,7 @@ token:
|
|||||||
# 重复提交
|
# 重复提交
|
||||||
repeat-submit:
|
repeat-submit:
|
||||||
# 全局间隔时间(毫秒)
|
# 全局间隔时间(毫秒)
|
||||||
intervalTime: 1000
|
interval: 5000
|
||||||
|
|
||||||
# MyBatisPlus配置
|
# MyBatisPlus配置
|
||||||
# https://baomidou.com/config/
|
# https://baomidou.com/config/
|
||||||
|
@ -96,7 +96,7 @@ public class TestDemoController extends BaseController {
|
|||||||
@ApiOperation("新增测试单表")
|
@ApiOperation("新增测试单表")
|
||||||
@PreAuthorize("@ss.hasPermi('demo:demo:add')")
|
@PreAuthorize("@ss.hasPermi('demo:demo:add')")
|
||||||
@Log(title = "测试单表", businessType = BusinessType.INSERT)
|
@Log(title = "测试单表", businessType = BusinessType.INSERT)
|
||||||
@RepeatSubmit(intervalTime = 2, timeUnit = TimeUnit.SECONDS)
|
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS, message = "不允许重复提交")
|
||||||
@PostMapping()
|
@PostMapping()
|
||||||
public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody TestDemoBo bo) {
|
public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody TestDemoBo bo) {
|
||||||
return toAjax(iTestDemoService.insertByBo(bo) ? 1 : 0);
|
return toAjax(iTestDemoService.insertByBo(bo) ? 1 : 0);
|
||||||
|
@ -39,11 +39,11 @@ public class RepeatSubmitAspect {
|
|||||||
@Before("@annotation(repeatSubmit)")
|
@Before("@annotation(repeatSubmit)")
|
||||||
public void doBefore(JoinPoint point, RepeatSubmit repeatSubmit) throws Throwable {
|
public void doBefore(JoinPoint point, RepeatSubmit repeatSubmit) throws Throwable {
|
||||||
// 如果注解不为0 则使用注解数值
|
// 如果注解不为0 则使用注解数值
|
||||||
long intervalTime = repeatSubmitProperties.getIntervalTime();
|
long interval = repeatSubmitProperties.getInterval();
|
||||||
if (repeatSubmit.intervalTime() > 0) {
|
if (repeatSubmit.interval() > 0) {
|
||||||
intervalTime = repeatSubmit.timeUnit().toMillis(repeatSubmit.intervalTime());
|
interval = repeatSubmit.timeUnit().toMillis(repeatSubmit.interval());
|
||||||
}
|
}
|
||||||
if (intervalTime < 1000) {
|
if (interval < 1000) {
|
||||||
throw new ServiceException("重复提交间隔时间不能小于'1'秒");
|
throw new ServiceException("重复提交间隔时间不能小于'1'秒");
|
||||||
}
|
}
|
||||||
HttpServletRequest request = ServletUtils.getRequest();
|
HttpServletRequest request = ServletUtils.getRequest();
|
||||||
@ -60,9 +60,9 @@ public class RepeatSubmitAspect {
|
|||||||
submitKey = SecureUtil.md5(submitKey + ":" + nowParams);
|
submitKey = SecureUtil.md5(submitKey + ":" + nowParams);
|
||||||
// 唯一标识(指定key + 消息头)
|
// 唯一标识(指定key + 消息头)
|
||||||
String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + submitKey;
|
String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + submitKey;
|
||||||
LockInfo lock = lockTemplate.lock(cacheRepeatKey, intervalTime, intervalTime / 2);
|
LockInfo lock = lockTemplate.lock(cacheRepeatKey, interval, interval / 2);
|
||||||
if (lock == null) {
|
if (lock == null) {
|
||||||
throw new ServiceException("不允许重复提交,请稍后再试!");
|
throw new ServiceException(repeatSubmit.message());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,6 @@ public class RepeatSubmitProperties {
|
|||||||
/**
|
/**
|
||||||
* 间隔时间(毫秒)
|
* 间隔时间(毫秒)
|
||||||
*/
|
*/
|
||||||
private int intervalTime;
|
private int interval;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user