Merge branch 'master' of https://gitee.com/rowger_217/im-system
This commit is contained in:
@@ -43,10 +43,11 @@ public class ImCallHistoryController {
|
||||
if(req.getLimit()!=null){
|
||||
Page<ImCallHistoryEntity> objectPage = new Page<>(req.getOffset(),req.getLimit());
|
||||
QueryWrapper<ImCallHistoryEntity> query=new QueryWrapper<>();
|
||||
query.eq("invite_id",req.getUid());
|
||||
// query.eq("invite_id",req.getUid());
|
||||
query.orderByDesc("create_time");
|
||||
IPage<ImCallHistoryEntity> imCallHistoryEntityIPage=callHistoryMapper.selectPage(objectPage,query);
|
||||
|
||||
|
||||
return ResponseVO.successResponse(imCallHistoryEntityIPage);
|
||||
}else {
|
||||
return ResponseVO.errorResponse();
|
||||
|
||||
@@ -18,9 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@@ -65,30 +63,27 @@ public class ImCallHistoryService {
|
||||
Integer i = Long.valueOf(seconds).intValue();
|
||||
imCallHistory.setContinueSecond(i);
|
||||
|
||||
log.error("===================结束之后通知客户端");
|
||||
log.error("===================结束之后通知客户端");
|
||||
log.error("===================结束之后通知客户端");
|
||||
|
||||
|
||||
|
||||
//TODO 结束之后通知客户端
|
||||
SendMessageReq req= new SendMessageReq();
|
||||
|
||||
req.setAppId(10000);
|
||||
req.setFromId(imCallHistory.getInviteId());
|
||||
req.setToId(imCallHistory.getPassiveId());
|
||||
req.setMessageTime(System.currentTimeMillis());
|
||||
|
||||
// req.setMessageRandom();
|
||||
|
||||
req.setMessageBody(JSONObject.toJSONString(imCallHistory));
|
||||
req.setMessageId(UUID.randomUUID().toString().replace("-", ""));
|
||||
|
||||
|
||||
|
||||
req.setImei("uniapp");
|
||||
req.setClientType(1);
|
||||
|
||||
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("userId", imCallHistory.getInviteId());
|
||||
data.put("msgType", "CALL_"+imCallHistory.getType());
|
||||
data.put("content", JSONObject.toJSONString(imCallHistory));
|
||||
|
||||
req.setMessageBody(JSONObject.toJSONString(data));
|
||||
|
||||
p2PMessageService.send(req);
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.lld.im.service.message.model.req.SendMessageReq;
|
||||
import com.lld.im.service.message.model.resp.ImMessageHistoryVo;
|
||||
import com.lld.im.service.message.service.MessageSyncService;
|
||||
import com.lld.im.service.message.service.P2PMessageService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -21,6 +22,7 @@ import java.util.List;
|
||||
* @author: lld
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("v1/message")
|
||||
public class MessageController {
|
||||
@@ -66,13 +68,16 @@ public class MessageController {
|
||||
|
||||
/**
|
||||
* 获取会话列表
|
||||
* @param req
|
||||
* @param chatHistoryReq
|
||||
* @param appId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/chatHistory")
|
||||
public ResponseVO chatHistory(@RequestBody
|
||||
@Validated ChatHistoryReq chatHistoryReq, Integer appId) {
|
||||
|
||||
|
||||
|
||||
chatHistoryReq.setAppId(appId);
|
||||
List<ImMessageHistoryVo> imMessageHistoryVos = messageSyncService.chatHistory(chatHistoryReq);
|
||||
return ResponseVO.successResponse(imMessageHistoryVos);
|
||||
|
||||
@@ -2,9 +2,11 @@ package com.lld.im.service.message.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.lld.im.service.message.dao.ImMessageHistoryEntity;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface ImMessageHistoryMapper extends BaseMapper<ImMessageHistoryEntity> {
|
||||
@@ -15,4 +17,8 @@ public interface ImMessageHistoryMapper extends BaseMapper<ImMessageHistoryEntit
|
||||
* @return
|
||||
*/
|
||||
Integer insertBatchSomeColumn(Collection<ImMessageHistoryEntity> entityList);
|
||||
|
||||
|
||||
@Select("select from_id,to_id,max(message_key) messageKey from im_message_history where owner_id = #{operater} group by from_id,to_id")
|
||||
List<ImMessageHistoryEntity> selectMessageByOwnId(String operater);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import java.util.Objects;
|
||||
* @author: lld
|
||||
* @version: 1.0
|
||||
*/
|
||||
|
||||
@Component
|
||||
public class ChatOperateReceiver {
|
||||
|
||||
|
||||
@@ -173,16 +173,33 @@ public class MessageSyncService {
|
||||
}
|
||||
|
||||
public List<ImMessageHistoryVo> chatHistory(ChatHistoryReq chatHistoryReq){
|
||||
// 1.清空缓存里对应的未读消息
|
||||
String key = chatHistoryReq.getAppId() + ":" + Constants.RedisConstants.OfflineMessage + ":" + chatHistoryReq.getOperater();
|
||||
ZSetOperations zSetOperations = redisTemplate.opsForZSet();
|
||||
Set querySet = zSetOperations.range(key,0,-1);
|
||||
for (Object o : querySet) {
|
||||
OfflineMessageContent offlineMessageContent = JSONObject.parseObject(o.toString(), OfflineMessageContent.class);
|
||||
if (chatHistoryReq.getUserId().equals(offlineMessageContent.getFromId()) || chatHistoryReq.getUserId().equals(offlineMessageContent.getToId())){
|
||||
zSetOperations.remove(key,o);
|
||||
}
|
||||
}
|
||||
// 2.获取聊天记录记录
|
||||
List<ImMessageHistoryVo> imMessageHistoryVos = new ArrayList<>();
|
||||
Page<ImMessageHistoryEntity> objectPage = new Page<>(chatHistoryReq.getOffset(),chatHistoryReq.getLimit());
|
||||
LambdaQueryWrapper<ImMessageHistoryEntity> and = new LambdaQueryWrapper<ImMessageHistoryEntity>().eq(ImMessageHistoryEntity::getOwnerId, chatHistoryReq.getOperater())
|
||||
.and(x -> x.eq(ImMessageHistoryEntity::getFromId, chatHistoryReq.getUserId()).or().eq(ImMessageHistoryEntity::getToId, chatHistoryReq.getUserId()))
|
||||
.orderByDesc(ImMessageHistoryEntity::getMessageKey);
|
||||
Page<ImMessageHistoryEntity> imMessageHistoryEntities = imMessageHistoryMapper.selectPage(objectPage,and);
|
||||
List<Long> messageKeys = imMessageHistoryEntities.getRecords().stream().map(x -> x.getMessageKey()).collect(Collectors.toList());
|
||||
|
||||
if (CollectionUtils.isEmpty(messageKeys)){
|
||||
return imMessageHistoryVos;
|
||||
}
|
||||
|
||||
List<ImMessageBodyEntity> imMessageBodyEntities = imMessageBodyMapper.selectList(new LambdaQueryWrapper<ImMessageBodyEntity>().in(ImMessageBodyEntity::getMessageKey, messageKeys));
|
||||
Map<Long, ImMessageBodyEntity> collect = imMessageBodyEntities.stream().collect(Collectors.toMap(ImMessageBodyEntity::getMessageKey, x -> x));
|
||||
|
||||
List<ImMessageHistoryVo> imMessageHistoryVos = BeanCopyUtils.copyList(imMessageHistoryEntities.getRecords(), ImMessageHistoryVo.class);
|
||||
imMessageHistoryVos = BeanCopyUtils.copyList(imMessageHistoryEntities.getRecords(), ImMessageHistoryVo.class);
|
||||
for (ImMessageHistoryVo imMessageHistoryVo : imMessageHistoryVos) {
|
||||
ImMessageBodyEntity imMessageBodyEntity = collect.get(imMessageHistoryVo.getMessageKey());
|
||||
imMessageHistoryVo.setMessageBody(imMessageBodyEntity.getMessageBody());
|
||||
|
||||
@@ -13,8 +13,8 @@ public class SRSStreamTask {
|
||||
@Scheduled(cron="0/5 * * * * ? ")
|
||||
public void executeTask(){
|
||||
String ip = System.getenv("SRS_HOST");
|
||||
|
||||
log.error("213132");
|
||||
log.info("========定时任务");
|
||||
//
|
||||
// log.error("213132");
|
||||
// log.info("========定时任务");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user