mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 07:03:53 +08:00
添加新接口和2个新方法
--AgentChatHistoryService.java 添加‘根据音频数据ID获取聊天内容’和‘查询此音频id是否属于此智能体’的方法定义 --AgentChatHistoryServiceImpl.java 实现2个新方法 --AgentController.java 增加一个获取音频内容的接口
This commit is contained in:
@@ -200,6 +200,16 @@ public class AgentController {
|
||||
return new Result<List<AgentChatHistoryUserVO>>().ok(data);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/chat-history/audio")
|
||||
@Operation(summary = "获取音频内容")
|
||||
@RequiresPermissions("sys:role:normal")
|
||||
public Result<String> getContentByAudioId(
|
||||
@PathVariable("id") String id) {
|
||||
// 查询聊天记录
|
||||
String data = agentChatHistoryService.getContentByAudioId(id);
|
||||
return new Result<String>().ok(data);
|
||||
}
|
||||
|
||||
@PostMapping("/audio/{audioId}")
|
||||
@Operation(summary = "获取音频下载ID")
|
||||
@RequiresPermissions("sys:role:normal")
|
||||
|
||||
+18
@@ -53,4 +53,22 @@ public interface AgentChatHistoryService extends IService<AgentChatHistoryEntity
|
||||
* @return 聊天记录列表(只有用户)
|
||||
*/
|
||||
List<AgentChatHistoryUserVO> getRecentlyFiftyByAgentId(String agentId);
|
||||
|
||||
/**
|
||||
* 根据音频数据ID获取聊天内容
|
||||
*
|
||||
* @param audioId 音频id
|
||||
* @return 聊天内容
|
||||
*/
|
||||
String getContentByAudioId(String audioId);
|
||||
|
||||
|
||||
/**
|
||||
* 查询此音频id是否属于此智能体
|
||||
*
|
||||
* @param audioId 音频id
|
||||
* @param agentId 音频id
|
||||
* @return T:属于 F:不属于
|
||||
*/
|
||||
boolean isAudioOwnedByAgent(String audioId,String agentId);
|
||||
}
|
||||
|
||||
+17
@@ -111,4 +111,21 @@ public class AgentChatHistoryServiceImpl extends ServiceImpl<AiAgentChatHistoryD
|
||||
ConvertUtils.sourceToTarget(item,AgentChatHistoryUserVO.class)
|
||||
).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentByAudioId(String audioId) {
|
||||
AgentChatHistoryEntity agentChatHistoryEntity = baseMapper.selectOne(new LambdaQueryWrapper<AgentChatHistoryEntity>()
|
||||
.select(AgentChatHistoryEntity::getContent)
|
||||
.eq(AgentChatHistoryEntity::getAudioId, audioId));
|
||||
return agentChatHistoryEntity == null ? null : agentChatHistoryEntity.getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAudioOwnedByAgent(String audioId, String agentId) {
|
||||
// 查询是否有指定音频id和智能体id的数据,如果有且只有一条说明此数据属性此智能体
|
||||
Long row = baseMapper.selectCount(new LambdaQueryWrapper<AgentChatHistoryEntity>()
|
||||
.eq(AgentChatHistoryEntity::getAudioId, audioId)
|
||||
.eq(AgentChatHistoryEntity::getAgentId, agentId));
|
||||
return row == 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user