|
@@ -2,6 +2,8 @@ package com.webchat.ugc.messaegqueue.service;
|
|
|
|
|
|
|
|
|
import com.webchat.common.bean.APIPageResponseBean;
|
|
|
+import com.webchat.common.bean.APIResponseBean;
|
|
|
+import com.webchat.common.bean.APIResponseBeanUtil;
|
|
|
import com.webchat.common.enums.ChatMessageTypeEnum;
|
|
|
import com.webchat.common.enums.RedisKeyEnum;
|
|
|
import com.webchat.common.enums.RoleCodeEnum;
|
|
@@ -14,12 +16,16 @@ import com.webchat.common.util.JsonUtil;
|
|
|
import com.webchat.domain.vo.request.mess.ChatMessageRequestVO;
|
|
|
import com.webchat.domain.vo.response.UserBaseResponseInfoVO;
|
|
|
import com.webchat.domain.vo.response.mess.ChatMessageResponseVO;
|
|
|
+import com.webchat.domain.vo.response.mess.PublicAccountArticleMessageVO;
|
|
|
+import com.webchat.domain.vo.response.publicaccount.ArticleBaseResponseVO;
|
|
|
+import com.webchat.rmi.pgc.OfficialArticleClient;
|
|
|
import com.webchat.ugc.repository.dao.IChatMessageDAO;
|
|
|
import com.webchat.ugc.repository.entity.ChatMessageEntity;
|
|
|
import com.webchat.ugc.service.AccountService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
@@ -55,6 +61,9 @@ public class PersistentMessageService {
|
|
|
@Autowired
|
|
|
private MessageQueueProducer<Object, Long> messageQueueProducer;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private OfficialArticleClient officialArticleClient;
|
|
|
+
|
|
|
/**
|
|
|
* 《离线场景》持久化消息队列,保存离线消息,同时会将数据同步到ES用于后续的RAG问答和消息搜索
|
|
|
*
|
|
@@ -289,12 +298,27 @@ public class PersistentMessageService {
|
|
|
if (ChatMessageTypeEnum.RED_PACKET.getType().equals(userMessEntity.getType())) {
|
|
|
// messageResponse.setRedPacketDetail(redPacketService.getRedPacketDetailCache(Long.valueOf(userMessEntity.getMessage())));
|
|
|
} else if (ChatMessageTypeEnum.PUBLIC_ACCOUNT_ARTICLE.getType().equals(userMessEntity.getType())) {
|
|
|
-// messageResponse.setPublicAccountArticle(articleService.getPublicAccountArticleMessage(Long.valueOf(userMessEntity.getMessage())));
|
|
|
+ messageResponse.setPublicAccountArticle(getArticleMessageVO(Long.valueOf(userMessEntity.getMessage())));
|
|
|
}
|
|
|
messageResponse.setGroupMessage(StringUtils.isNotBlank(userMessEntity.getProxySender()));
|
|
|
return messageResponse;
|
|
|
}
|
|
|
|
|
|
+ private PublicAccountArticleMessageVO getArticleMessageVO(Long articleId) {
|
|
|
+ APIResponseBean<ArticleBaseResponseVO> responseBean = officialArticleClient.detail(articleId, false);
|
|
|
+ if (!APIResponseBeanUtil.isOk(responseBean)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ ArticleBaseResponseVO articleBaseResponseVO = responseBean.getData();
|
|
|
+ if (articleBaseResponseVO == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ PublicAccountArticleMessageVO articleMessageVO = new PublicAccountArticleMessageVO();
|
|
|
+ BeanUtils.copyProperties(articleBaseResponseVO, articleMessageVO);
|
|
|
+ articleMessageVO.setArticleId(articleBaseResponseVO.getId());
|
|
|
+ return articleMessageVO;
|
|
|
+ }
|
|
|
+
|
|
|
public String getUserMessRedisKey(String sender, String receiver) {
|
|
|
return RedisKeyEnum.USER_CHAT_MESS_CACHE_KEY.getKey(sender, receiver);
|
|
|
}
|