12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package com.webchat.client.mall.service;
- import com.webchat.common.bean.APIResponseBean;
- import com.webchat.common.bean.APIResponseBeanUtil;
- import com.webchat.common.exception.BusinessException;
- import com.webchat.common.util.JsonUtil;
- import com.webchat.domain.vo.response.chatting.ChattingListResponseVO;
- import com.webchat.domain.vo.response.mess.ChatMessageResponseVO;
- import com.webchat.rmi.ugc.ChatMessageClient;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.Collections;
- import java.util.List;
- @Slf4j
- @Service
- public class ChatMessageService {
- @Autowired
- private ChatMessageClient chatMessageClient;
- public List<ChatMessageResponseVO> list(String currentUserId, String chatUserId, Long lastId, Long fixedMessageId, Integer size) {
- APIResponseBean<List<ChatMessageResponseVO>> messageResponse = chatMessageClient.list(currentUserId, chatUserId, size, lastId, fixedMessageId);
- if (APIResponseBeanUtil.isOk(messageResponse)) {
- return messageResponse.getData();
- }
- return Collections.emptyList();
- }
- public List<ChattingListResponseVO> listChatting(String userId, Long lastChatTime, Integer size) {
- // RPC 远程调用,请求 UGC 核心服务获取对话列表数据
- APIResponseBean<List<ChattingListResponseVO>> responseBean = chatMessageClient.listChatting(userId, lastChatTime, size);
- if (APIResponseBeanUtil.isOk(responseBean)) {
- return responseBean.getData();
- }
- log.error("chatMessageClient.listChatting RPC invoke error =====> " +
- "userId:{}, lastChatTime:{}, size:{}, response:{}", userId, lastChatTime, size, JsonUtil.toJsonString(responseBean));
- throw new BusinessException(responseBean.getMsg());
- }
- }
|