|
@@ -1,8 +1,11 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.microsvc.toolkit.middleware.live.LivePluginContext;
|
|
|
import com.microsvc.toolkit.middleware.live.message.LiveRoomMessage;
|
|
|
+import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
+import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dao.LiveGoodsMapperDao;
|
|
|
import com.ym.mec.biz.dal.dto.LiveGoodsMapperDto;
|
|
|
import com.ym.mec.biz.dal.dto.RedisKeyConstant;
|
|
@@ -18,6 +21,7 @@ import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -27,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class LiveGoodsMapperServiceImpl extends BaseServiceImpl<Integer, LiveGoodsMapper> implements LiveGoodsMapperService {
|
|
|
|
|
|
@Autowired
|
|
@@ -40,6 +45,8 @@ public class LiveGoodsMapperServiceImpl extends BaseServiceImpl<Integer, LiveGoo
|
|
|
@Autowired
|
|
|
private RedissonClient redissonClient;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, LiveGoodsMapper> getDAO() {
|
|
@@ -104,17 +111,41 @@ public class LiveGoodsMapperServiceImpl extends BaseServiceImpl<Integer, LiveGoo
|
|
|
}
|
|
|
|
|
|
private void publishRoomMsg(ImLiveBroadcastRoom imLiveBroadcastRoom) {
|
|
|
- LiveRoomMessage message = new LiveRoomMessage();
|
|
|
- message.setIsIncludeSender(1);
|
|
|
- message.setObjectName(ImRoomMessage.LIVE_GOODS_CHANGE);
|
|
|
- message.setToChatRoomId(imLiveBroadcastRoom.getRoomUid());
|
|
|
- message.setFromUserId(imLiveBroadcastRoom.getSpeakerId().toString());
|
|
|
- message.setContent(liveGoodsMapperDao.getLiveGoodsList(imLiveBroadcastRoom.getRoomUid(),null,true));
|
|
|
+
|
|
|
+
|
|
|
+ // 消息发送用户
|
|
|
+ LiveRoomMessage.MessageUser messageUser = null;
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserById(imLiveBroadcastRoom.getSpeakerId());
|
|
|
+ if (Objects.nonNull(sysUser)) {
|
|
|
+ // 发送用户信息
|
|
|
+ messageUser = LiveRoomMessage.MessageUser
|
|
|
+ .builder()
|
|
|
+ .sendUserId(sysUser.getId().toString())
|
|
|
+ .sendUserName(sysUser.getUsername())
|
|
|
+ .avatarUrl(sysUser.getAvatar())
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ LiveRoomMessage.MessageContent messageContent = LiveRoomMessage.MessageContent
|
|
|
+ .builder()
|
|
|
+ .sendUserInfo(messageUser)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ LiveRoomMessage message = LiveRoomMessage.builder()
|
|
|
+ .isIncludeSender(1)
|
|
|
+ .objectName(LiveRoomMessage.LIVE_GOODS_CHANGE)
|
|
|
+ .fromUserId(sysUser.getId().toString())
|
|
|
+ .toChatRoomId(imLiveBroadcastRoom.getRoomUid())
|
|
|
+ .content(liveGoodsMapperDao.getLiveGoodsList(imLiveBroadcastRoom.getRoomUid(),null,true))
|
|
|
+ .build();
|
|
|
+
|
|
|
+ //发送消息
|
|
|
try {
|
|
|
- livePluginContext.getPluginService(imLiveBroadcastRoom.getServiceProvider())
|
|
|
- .sendChatRoomMessage(message);
|
|
|
+ livePluginContext.getPluginService(imLiveBroadcastRoom.getServiceProvider()).sendChatRoomMessage(message);
|
|
|
+ log.info("LIVE_GOODS_CHANGE>>>> message: {}", JSONObject.toJSONString(message));
|
|
|
} catch (Exception e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
+ log.error("LIVE_GOODS_CHANGE>>>> error {}", e.getMessage());
|
|
|
+ log.error("LIVE_GOODS_CHANGE>>>> sendMessage {} :", JSONObject.toJSONString(message));
|
|
|
}
|
|
|
}
|
|
|
|