|
@@ -3,7 +3,9 @@ package com.doc.chat.service.impl;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.doc.biz.service.IDocInfoService;
|
|
|
import com.doc.chat.domain.ChatMsg;
|
|
|
+import com.doc.chat.domain.ChatMsgRecord;
|
|
|
import com.doc.chat.mapper.ChatMsgMapper;
|
|
|
+import com.doc.chat.service.IChatMsgRecordService;
|
|
|
import com.doc.chat.service.IChatMsgService;
|
|
|
import com.doc.common.constant.CacheConstants;
|
|
|
import com.doc.common.core.domain.entity.SysUser;
|
|
@@ -36,6 +38,8 @@ public class ChatMsgServiceImpl implements IChatMsgService {
|
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
|
@Resource
|
|
|
private IDocInfoService docInfoService;
|
|
|
+ @Resource
|
|
|
+ private IChatMsgRecordService recordService;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -71,7 +75,20 @@ public class ChatMsgServiceImpl implements IChatMsgService {
|
|
|
String idIndex = getIdIndex(chatMsg.getFromId(), chatMsg.getToId());
|
|
|
chatMsg.setIdIndex(idIndex);
|
|
|
chatMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
- return chatMsgMapper.insertChatMsg(chatMsg);
|
|
|
+ int i = chatMsgMapper.insertChatMsg(chatMsg);
|
|
|
+ if (chatMsg.getFromId() != -1) {
|
|
|
+ //如果是系统消息则不用管
|
|
|
+ ChatMsgRecord from = new ChatMsgRecord();
|
|
|
+ from.setMsgId(chatMsg.getMsgId());
|
|
|
+ from.setUserId(chatMsg.getFromId());
|
|
|
+ recordService.insertChatMsgRecord(from);
|
|
|
+ }
|
|
|
+ ChatMsgRecord to = new ChatMsgRecord();
|
|
|
+ to.setMsgId(chatMsg.getMsgId());
|
|
|
+ to.setUserId(chatMsg.getToId());
|
|
|
+ recordService.insertChatMsgRecord(to);
|
|
|
+
|
|
|
+ return i;
|
|
|
}
|
|
|
|
|
|
private String getIdIndex(Long fromId, Long toId) {
|
|
@@ -176,6 +193,18 @@ public class ChatMsgServiceImpl implements IChatMsgService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 删除聊天记录
|
|
|
+ *
|
|
|
+ * @param userId 用户ID
|
|
|
+ * @param toId 对方ID
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int delRecord(Long userId, Long toId) {
|
|
|
+ return recordService.delRecord(userId, getIdIndex(userId, toId));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 设置用户及文件信息
|
|
|
*
|
|
|
* @param msgList 消息列表
|