|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.cloud.kicc.system.service.impl; |
|
|
|
package com.cloud.kicc.system.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.convert.Convert; |
|
|
|
import cn.hutool.core.io.FileUtil; |
|
|
|
import cn.hutool.core.io.FileUtil; |
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
@ -67,7 +68,7 @@ public class ImContentServiceImpl extends ServiceImpl<ImContentMapper, ImContent |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@SneakyThrows |
|
|
|
@SneakyThrows |
|
|
|
public ImContent completions(ImContent imContent, MultipartFile file) { |
|
|
|
public Map<String, Object> completions(ImContent imContent, MultipartFile file) { |
|
|
|
SecurityUtils.openInterfaceTemporaryLoginSession(imContent.getSendUserId()); |
|
|
|
SecurityUtils.openInterfaceTemporaryLoginSession(imContent.getSendUserId()); |
|
|
|
if (imContent.getContentType().equals(ImMessageTypeEnum.AUDIO.getValue())) { |
|
|
|
if (imContent.getContentType().equals(ImMessageTypeEnum.AUDIO.getValue())) { |
|
|
|
Optional.ofNullable(file).orElseThrow(() -> new CheckedException("当前语音文件为空,请检查后重试!")); |
|
|
|
Optional.ofNullable(file).orElseThrow(() -> new CheckedException("当前语音文件为空,请检查后重试!")); |
|
|
@ -133,14 +134,17 @@ public class ImContentServiceImpl extends ServiceImpl<ImContentMapper, ImContent |
|
|
|
fileService.save(receiveOssOssFile); |
|
|
|
fileService.save(receiveOssOssFile); |
|
|
|
|
|
|
|
|
|
|
|
// 保存AI回复聊天记录
|
|
|
|
// 保存AI回复聊天记录
|
|
|
|
imContent.setFiles(receiveOssOssFile.getId()); |
|
|
|
content.setFiles(receiveOssOssFile.getId()); |
|
|
|
super.save(content); |
|
|
|
super.save(content); |
|
|
|
return content; |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> result = Convert.toMap(String.class, Object.class, content); |
|
|
|
|
|
|
|
result.putAll(Convert.toMap(String.class, Object.class, receiveOssOssFile)); |
|
|
|
|
|
|
|
return result; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// 保存AI回复聊天记录
|
|
|
|
// 保存AI回复聊天记录
|
|
|
|
ImContent content = askChatCompletion(imContent); |
|
|
|
ImContent content = askChatCompletion(imContent); |
|
|
|
super.save(content); |
|
|
|
super.save(content); |
|
|
|
return content; |
|
|
|
return Convert.toMap(String.class, Object.class, content); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|