增加配置

This commit is contained in:
GYJ
2025-03-06 15:34:07 +08:00
parent d5941e5ed0
commit 98e1b9a345
4 changed files with 39 additions and 27 deletions

View File

@@ -265,7 +265,10 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
log.info("操作过于频繁请稍后再试userId:{}", userId);
return Result.error("操作过于频繁,请稍后再试!");
}
redisService.setUserCanCreateOrder(userId);
long seconds = Long.parseLong(commonInfoService.findOne(934).getValue());
redisService.setUserCanCreateOrder(userId, seconds);
UserEntity userEntity = userService.getById(userId);
if (userEntity == null) {
throw new SqxException("用户不存在");

View File

@@ -39,7 +39,7 @@ public interface RedisService {
* 设置用户上次创建订单时间
* @param userId 用户id
*/
void setUserCanCreateOrder(Long userId);
void setUserCanCreateOrder(Long userId, Long seconds);
/**
* 判断用户是否可以创建订单 30s 内只能创建一次订单

View File

@@ -363,9 +363,9 @@ public class RedisServiceImpl implements RedisService {
}
@Override
public void setUserCanCreateOrder(Long userId) {
public void setUserCanCreateOrder(Long userId, Long seconds) {
String key = "user:canCreateOrder:" + userId;
redisTemplate.opsForValue().set(key, "1", 30, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(key, "1", seconds, TimeUnit.SECONDS);
}
@Override