增加配置
This commit is contained in:
@@ -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("用户不存在");
|
||||
|
||||
@@ -39,7 +39,7 @@ public interface RedisService {
|
||||
* 设置用户上次创建订单时间
|
||||
* @param userId 用户id
|
||||
*/
|
||||
void setUserCanCreateOrder(Long userId);
|
||||
void setUserCanCreateOrder(Long userId, Long seconds);
|
||||
|
||||
/**
|
||||
* 判断用户是否可以创建订单 30s 内只能创建一次订单
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user