|
@@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -56,13 +57,11 @@ public class CommunityChatMsgController extends BaseController {
|
|
|
.orderByDesc("create_time"));
|
|
|
//更新该消息标记为已读
|
|
|
List<Long> msgId = chatMsgList.stream()
|
|
|
- .filter(item -> !item.isRead())
|
|
|
+ .filter(item -> !item.isReceiverIsRead() && Objects.equals(item.getReceiverId(), SecurityUtils.getUserId()))
|
|
|
.map(CommunityChatMsg::getId)
|
|
|
.collect(Collectors.toList());
|
|
|
if (!msgId.isEmpty()) {
|
|
|
- CommunityChatMsg chatMsg = new CommunityChatMsg();
|
|
|
- chatMsg.setRead(true);
|
|
|
- communityChatMsgService.update(chatMsg, new UpdateWrapper<CommunityChatMsg>().in("id", msgId));
|
|
|
+ communityChatMsgService.update(new UpdateWrapper<CommunityChatMsg>().in("id", msgId).set("receiver_is_read", true));
|
|
|
}
|
|
|
|
|
|
List<CommunityChatMsgVo> chatMsgVos = new ArrayList<>();
|
|
@@ -72,6 +71,12 @@ public class CommunityChatMsgController extends BaseController {
|
|
|
BeanUtils.copyProperties(chatMsg, chatMsgVo);
|
|
|
SysUser senderUser = sysUserMapper.selectUserById(chatMsgVo.getSenderId());
|
|
|
SysUser receiveUser = sysUserMapper.selectUserById(chatMsgVo.getReceiverId());
|
|
|
+ if (!msgId.isEmpty()) {
|
|
|
+ boolean contains = msgId.contains(chatMsg.getId());
|
|
|
+ if (contains) {
|
|
|
+ chatMsgVo.setReceiverIsRead(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
chatMsgVo.setSenderNickName(senderUser.getNickName());
|
|
|
chatMsgVo.setSenderAvatar(senderUser.getAvatar());
|
|
|
chatMsgVo.setReceiverNickName(receiveUser.getNickName());
|