From 9405b0d6300ce6c85b9e58b7a289db75e9f7e2e1 Mon Sep 17 00:00:00 2001 From: xupei Date: Thu, 4 Jan 2024 17:34:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=9C=BA=E5=99=A8=E4=BA=BA?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=9B=BE=E7=89=87=E5=9C=B0=E5=9D=80=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=AE=9E=E9=99=85=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../da/service/impl/ChatRobotServiceImpl.java | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java b/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java index 0adca4d0..e94c5a3c 100644 --- a/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java @@ -162,6 +162,7 @@ public class ChatRobotServiceImpl implements ChatRobotService { String responseBody = response.body().string(); JSONObject responseObject = JSON.parseObject(responseBody); JSONObject data = responseObject.getJSONObject("data"); + log.info(String.valueOf(data)); if (null != data) { ChatRobot chatRobot = new ChatRobot(); chatRobot.setResponseType(data.getString("response_type")); @@ -200,20 +201,26 @@ public class ChatRobotServiceImpl implements ChatRobotService { String prefix = getPrefix(array.getString(i),chatSendDTO.getGender()); String path = prefix; // String path = prefix + array.getString(i); - QueryWrapper qw = new QueryWrapper<>(); - qw.lambda().eq(Library::getUrl, bucketName + "/" + path); - qw.lambda().eq(Library::getAccountId, chatSendDTO.getUser_id()); - qw.lambda().last("limit 1"); - List libraryList = libraryMapper.selectList(qw); - if (!CollectionUtils.isEmpty(libraryList)) { - chatRobotLibraryVO.setId(libraryList.get(0).getId()); + if (minioUtil.doesObjectExist(bucketName,path)){ + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().eq(Library::getUrl, bucketName + "/" + path); + qw.lambda().eq(Library::getAccountId, chatSendDTO.getUser_id()); + qw.lambda().last("limit 1"); + List libraryList = libraryMapper.selectList(qw); + if (!CollectionUtils.isEmpty(libraryList)) { + chatRobotLibraryVO.setId(libraryList.get(0).getId()); + } + String aidaSysImage = minioUtil.getPresignedUrl(bucketName + "/" + path, 24 * 60); + chatRobotLibraryVO.setUrl(bucketName + "/" + path); + chatRobotLibraryVO.setPresignedUrl(aidaSysImage); + chatRobotLibraryVOList.add(chatRobotLibraryVO); } - String aidaSysImage = minioUtil.getPresignedUrl(bucketName + "/" + path, 24 * 60); - chatRobotLibraryVO.setUrl(bucketName + "/" + path); - chatRobotLibraryVO.setPresignedUrl(aidaSysImage); - chatRobotLibraryVOList.add(chatRobotLibraryVO); } - chatRobotVO.setChatRobotLibraryList(chatRobotLibraryVOList); + if (!CollectionUtils.isEmpty(chatRobotLibraryVOList)){ + chatRobotVO.setChatRobotLibraryList(chatRobotLibraryVOList); + }else { + chatRobotVO.setOutput("I'm sorry, but I can't process your current request. Please rephrase it differently."); + } } } else { chatRobot.setSuccessful(0);