This commit is contained in:
77
2024-08-05 16:11:08 +08:00
parent 3706411b80
commit 7f446e774f
2 changed files with 4 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ import lombok.Data;
public class AnchorTopResp {
@Schema(description = "置顶是否成功")
private boolean topSuccess;
// private String topFailMessage;
@Schema(description = "下一次置顶间隔(秒)")
private Long nextTopDate = 0L;
}

View File

@@ -302,12 +302,13 @@ public class CurrentUserManager {
if(lock.isLocked()){
throw new ServiceException("操作太频繁");
}
long inter = 0;
try {
lock.lock(3, TimeUnit.SECONDS);
String userGreetSendTime = String.format(RedisHttpConstant.ANCHOR_TOP_TIME_REDIS,userId); // 最近一次的发送时间
String lastTime = stringRedisTemplate.opsForValue().get(userGreetSendTime);
if(StringUtils.isNotBlank(lastTime)){
int inter = systemConfigManager.getSystemConfigOfInt(SystemConfigEnum.ANCHOR_TOP_MIN) * 60;
inter = systemConfigManager.getSystemConfigOfInt(SystemConfigEnum.ANCHOR_TOP_MIN) * 60;
long jiange = DateUtil.currentSeconds() - Long.parseLong(lastTime); // 距离上次发送的间隔
long diff = inter - jiange;
if(diff > 0){
@@ -326,6 +327,7 @@ public class CurrentUserManager {
}
AnchorTopResp resp = new AnchorTopResp();
resp.setTopSuccess(true);
resp.setNextTopDate(inter);
return resp;
}
}