Commit 75e4555b by 罗长华

消息数量控制修改按天

parent 229eeaf5
...@@ -8,6 +8,7 @@ import io.swagger.annotations.Api; ...@@ -8,6 +8,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -390,7 +391,7 @@ public class NormalChatAction { ...@@ -390,7 +391,7 @@ public class NormalChatAction {
} }
int sendCount = int sendCount =
imMessageService.count(Wrappers.<ImMessage>lambdaQuery().eq(ImMessage::getFkConversationId, imMessageService.count(Wrappers.<ImMessage>lambdaQuery().eq(ImMessage::getFkConversationId,
conversationId).eq(ImMessage::getSender, imClientSender.getId())); conversationId).eq(ImMessage::getSender, imClientSender.getId()).between(ImMessage::getCreateTime, getStartTime(), getEndTime()));
if (!isVip) { if (!isVip) {
// 判断消息发送数量 // 判断消息发送数量
if (sendCount >= 3) { if (sendCount >= 3) {
...@@ -555,5 +556,23 @@ public class NormalChatAction { ...@@ -555,5 +556,23 @@ public class NormalChatAction {
} }
private Date getStartTime() {
Calendar todayStart = Calendar.getInstance();
todayStart.set(Calendar.HOUR_OF_DAY, 0);
todayStart.set(Calendar.MINUTE, 0);
todayStart.set(Calendar.SECOND, 0);
todayStart.set(Calendar.MILLISECOND, 0);
return todayStart.getTime();
}
private Date getEndTime() {
Calendar todayEnd = Calendar.getInstance();
todayEnd.set(Calendar.HOUR_OF_DAY, 23);
todayEnd.set(Calendar.MINUTE, 59);
todayEnd.set(Calendar.SECOND, 59);
todayEnd.set(Calendar.MILLISECOND, 999);
return todayEnd.getTime();
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment