Commit c84faeb9 by 段启岩

更新消息

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