判断机器人返回图片地址是否实际存在
This commit is contained in:
@@ -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<Library> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(Library::getUrl, bucketName + "/" + path);
|
||||
qw.lambda().eq(Library::getAccountId, chatSendDTO.getUser_id());
|
||||
qw.lambda().last("limit 1");
|
||||
List<Library> libraryList = libraryMapper.selectList(qw);
|
||||
if (!CollectionUtils.isEmpty(libraryList)) {
|
||||
chatRobotLibraryVO.setId(libraryList.get(0).getId());
|
||||
if (minioUtil.doesObjectExist(bucketName,path)){
|
||||
QueryWrapper<Library> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(Library::getUrl, bucketName + "/" + path);
|
||||
qw.lambda().eq(Library::getAccountId, chatSendDTO.getUser_id());
|
||||
qw.lambda().last("limit 1");
|
||||
List<Library> 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);
|
||||
|
||||
Reference in New Issue
Block a user