From 7cf44f236e049a6914febac3b42c0feee8b2be97 Mon Sep 17 00:00:00 2001 From: lhpqaq <657407891@qq.com> Date: Tue, 3 Dec 2024 15:21:25 +0800 Subject: [PATCH] add detail --- .../model/converter/ChatThreadConverter.java | 8 +++++++- .../manager/server/model/vo/ChatThreadVO.java | 4 ++++ .../server/service/impl/ChatbotServiceImpl.java | 15 +++++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ChatThreadConverter.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ChatThreadConverter.java index 59aa3fae..b28b3700 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ChatThreadConverter.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ChatThreadConverter.java @@ -18,12 +18,15 @@ */ package org.apache.bigtop.manager.server.model.converter; +import org.apache.bigtop.manager.dao.po.AuthPlatformPO; import org.apache.bigtop.manager.dao.po.ChatThreadPO; +import org.apache.bigtop.manager.dao.po.PlatformPO; import org.apache.bigtop.manager.server.config.MapStructSharedConfig; import org.apache.bigtop.manager.server.model.dto.ChatThreadDTO; import org.apache.bigtop.manager.server.model.req.ChatbotThreadReq; import org.apache.bigtop.manager.server.model.vo.ChatThreadVO; +import org.mapstruct.Context; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; @@ -35,7 +38,10 @@ public interface ChatThreadConverter { ChatThreadConverter INSTANCE = Mappers.getMapper(ChatThreadConverter.class); @Mapping(source = "id", target = "threadId") - ChatThreadVO fromPO2VO(ChatThreadPO platformAuthorizedPO); + @Mapping(target = "model", expression = "java(authPlatformPO.getModel())") + @Mapping(target = "platformName", expression = "java(platformPO.getName())") + ChatThreadVO fromPO2VO( + ChatThreadPO platformAuthorizedPO, @Context AuthPlatformPO authPlatformPO, @Context PlatformPO platformPO); ChatThreadPO fromDTO2PO(ChatThreadDTO chatThreadDTO); diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/ChatThreadVO.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/ChatThreadVO.java index ce49396b..846bbc39 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/ChatThreadVO.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/ChatThreadVO.java @@ -30,6 +30,10 @@ public class ChatThreadVO { private String name; + private String platformName; + + private String model; + private String createTime; private String updateTime; diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ChatbotServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ChatbotServiceImpl.java index 777ab200..2ab8acde 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ChatbotServiceImpl.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ChatbotServiceImpl.java @@ -140,7 +140,7 @@ public ChatThreadVO createChatThread(ChatThreadDTO chatThreadDTO) { ChatThreadPO chatThreadPO = ChatThreadConverter.INSTANCE.fromDTO2PO(chatThreadDTO); chatThreadPO.setUserId(userId); chatThreadDao.save(chatThreadPO); - return ChatThreadConverter.INSTANCE.fromPO2VO(chatThreadPO); + return ChatThreadConverter.INSTANCE.fromPO2VO(chatThreadPO, authPlatformPO, platformPO); } @Override @@ -165,6 +165,8 @@ public List getAllChatThreads() { if (authPlatformPO == null) { throw new ApiException(ApiExceptionEnum.NO_PLATFORM_IN_USE); } + PlatformPO platformPO = platformDao.findById(authPlatformPO.getPlatformId()); + Long authId = authPlatformPO.getId(); Long userId = SessionUserHolder.getUserId(); List chatThreadPOS = chatThreadDao.findAllByAuthIdAndUserId(authId, userId); @@ -173,7 +175,8 @@ public List getAllChatThreads() { if (chatThreadPO.getIsDeleted()) { continue; } - ChatThreadVO chatThreadVO = ChatThreadConverter.INSTANCE.fromPO2VO(chatThreadPO); + ChatThreadVO chatThreadVO = + ChatThreadConverter.INSTANCE.fromPO2VO(chatThreadPO, authPlatformPO, platformPO); chatThreads.add(chatThreadVO); } return chatThreads; @@ -282,7 +285,9 @@ public ChatThreadVO updateChatThread(ChatThreadDTO chatThreadDTO) { chatThreadPO.setName(chatThreadDTO.getName()); chatThreadDao.partialUpdateById(chatThreadPO); - return ChatThreadConverter.INSTANCE.fromPO2VO(chatThreadPO); + AuthPlatformPO authPlatformPO = authPlatformDao.findById(chatThreadPO.getAuthId()); + return ChatThreadConverter.INSTANCE.fromPO2VO( + chatThreadPO, authPlatformPO, platformDao.findById(authPlatformPO.getPlatformId())); } @Override @@ -295,6 +300,8 @@ public ChatThreadVO getChatThread(Long threadId) { if (!chatThreadPO.getUserId().equals(userId)) { throw new ApiException(ApiExceptionEnum.PERMISSION_DENIED); } - return ChatThreadConverter.INSTANCE.fromPO2VO(chatThreadPO); + AuthPlatformPO authPlatformPO = authPlatformDao.findById(chatThreadPO.getAuthId()); + return ChatThreadConverter.INSTANCE.fromPO2VO( + chatThreadPO, authPlatformPO, platformDao.findById(authPlatformPO.getPlatformId())); } }