Commit c84faeb9 by 段启岩

更新消息

parent af125485
......@@ -33,7 +33,7 @@ public class Message implements Serializable {
private String messageId;
@ApiModelProperty(value = "消息发送者ID")
private String from;
private String fromId;
@ApiModelProperty(value = "消息发送者昵称")
private String fromName;
......@@ -42,7 +42,7 @@ public class Message implements Serializable {
private String fromAvatar;
@ApiModelProperty(value = "消息接收者ID")
private String to;
private String toId;
@ApiModelProperty(value = "消息类型")
private Integer msgType;
......
......@@ -297,18 +297,18 @@ public class MessageListener implements DataItemChangeListener {
if (subject.isAuthenticated()) {
String from = (String) subject.getId();
User user = userService.getById(from);
message.setFrom(from);
message.setFromId(from);
message.setFromName(user.getNickName());
message.setFromAvatar(user.getUserAvatar());
} else {
message.setFrom(SysConstants.SYS_ID);
message.setFromId(SysConstants.SYS_ID);
message.setFromName(SysConstants.SYS_ID);
message.setFromName(SysConstants.SYS_NAME);
message.setFromAvatar("");
}
message.setMsgType(msgType);
message.setMsgContent(msg);
message.setTo(to);
message.setToId(to);
messageService.save(message);
Integer totalCount = messageService.getTotalCount(to);
......
......@@ -38,7 +38,7 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> impl
@Override
public void readMessages(String userId) {
UpdateWrapper updateWrapper = new UpdateWrapper();
updateWrapper.eq("to", userId);
updateWrapper.eq("to_id", userId);
updateWrapper.set("status", MessageStatus.READ.getStatus());
update(updateWrapper);
}
......@@ -48,7 +48,7 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> impl
IPage<Message> page = new Page<>(pageNumber, pageSize);
QueryWrapper<Message> messageQueryWrapper = new QueryWrapper<>();
messageQueryWrapper.eq("to", userId);
messageQueryWrapper.eq("to_id", userId);
messageQueryWrapper.orderByDesc("create_time");
return page(page, messageQueryWrapper);
}
......@@ -73,7 +73,7 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> impl
QueryWrapper<Message> messageQueryWrapper = new QueryWrapper<>();
messageQueryWrapper
.eq("message_id",messageId)
.eq("to",userId);
.eq("to_id",userId);
Message message = getOne(messageQueryWrapper);
//2. 若找不到该消息,抛出业务异常
......@@ -89,7 +89,7 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> impl
public void deleteAllMessage(String userId) {
QueryWrapper<Message> messageQueryWrapper = new QueryWrapper<>();
messageQueryWrapper.eq("to",userId);
messageQueryWrapper.eq("to_id",userId);
remove(messageQueryWrapper);
}
......@@ -97,14 +97,14 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> impl
@Override
public Integer getTotalCount(String to) {
QueryWrapper<Message> messageQueryWrapper = new QueryWrapper<>();
messageQueryWrapper.eq("to", to);
messageQueryWrapper.eq("to_id", to);
return count(messageQueryWrapper);
}
@Override
public Integer getUnReadCount(String to) {
QueryWrapper<Message> messageQueryWrapper = new QueryWrapper<>();
messageQueryWrapper.eq("to", to);
messageQueryWrapper.eq("to_id", to);
messageQueryWrapper.eq("status", 0);
return count(messageQueryWrapper);
}
......
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