mirror of
https://gitee.com/yudaocode/yudao-boot-mini.git
synced 2026-10-06 14:13:14 +08:00
feat(ai): 增加更多 get 获取详情接口
This commit is contained in:
+14
@@ -106,6 +106,20 @@ public class AiChatConversationController {
|
||||
conversation -> conversation.setMessageCount(messageCountMap.getOrDefault(conversation.getId(), 0))));
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得对话", description = "用于【对话管理】菜单")
|
||||
@Parameter(name = "id", required = true, description = "对话编号", example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('ai:chat-conversation:query')")
|
||||
@TransMethodResult
|
||||
public CommonResult<AiChatConversationRespVO> getChatConversation(@RequestParam("id") Long id) {
|
||||
AiChatConversationDO conversation = chatConversationService.getChatConversation(id);
|
||||
AiChatConversationRespVO respVO = BeanUtils.toBean(conversation, AiChatConversationRespVO.class);
|
||||
if (respVO != null) {
|
||||
respVO.setMessageCount(chatMessageService.getChatMessageCount(id));
|
||||
}
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "管理员删除对话")
|
||||
@DeleteMapping("/delete-by-admin")
|
||||
@Parameter(name = "id", required = true, description = "对话编号", example = "1024")
|
||||
|
||||
+15
-1
@@ -131,7 +131,7 @@ public class AiChatMessageController {
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得消息分页", description = "用于【对话管理】菜单")
|
||||
@PreAuthorize("@ss.hasPermission('ai:chat-conversation:query')")
|
||||
@PreAuthorize("@ss.hasPermission('ai:chat-message:query')")
|
||||
public CommonResult<PageResult<AiChatMessageRespVO>> getChatMessagePage(AiChatMessagePageReqVO pageReqVO) {
|
||||
PageResult<AiChatMessageDO> pageResult = chatMessageService.getChatMessagePage(pageReqVO);
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
@@ -145,6 +145,20 @@ public class AiChatMessageController {
|
||||
role -> respVO.setRoleName(role.getName()))));
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得消息", description = "用于【对话管理】菜单")
|
||||
@Parameter(name = "id", required = true, description = "消息编号", example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('ai:chat-message:query')")
|
||||
public CommonResult<AiChatMessageRespVO> getChatMessage(@RequestParam("id") Long id) {
|
||||
AiChatMessageDO message = chatMessageService.getChatMessage(id);
|
||||
AiChatMessageRespVO respVO = BeanUtils.toBean(message, AiChatMessageRespVO.class);
|
||||
if (respVO != null && respVO.getRoleId() != null) {
|
||||
AiChatRoleDO role = chatRoleService.getChatRole(respVO.getRoleId());
|
||||
respVO.setRoleName(role != null ? role.getName() : null);
|
||||
}
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "管理员删除消息")
|
||||
@DeleteMapping("/delete-by-admin")
|
||||
@Parameter(name = "id", required = true, description = "消息编号", example = "1024")
|
||||
|
||||
+10
-1
@@ -119,6 +119,15 @@ public class AiImageController {
|
||||
return success(BeanUtils.toBean(pageResult, AiImageRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得绘画")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('ai:image:query')")
|
||||
public CommonResult<AiImageRespVO> getImage(@RequestParam("id") Long id) {
|
||||
AiImageDO image = imageService.getImage(id);
|
||||
return success(BeanUtils.toBean(image, AiImageRespVO.class));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新绘画")
|
||||
@PreAuthorize("@ss.hasPermission('ai:image:update')")
|
||||
@@ -136,4 +145,4 @@ public class AiImageController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -46,6 +46,15 @@ public class AiMindMapController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得思维导图")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('ai:mind-map:query')")
|
||||
public CommonResult<AiMindMapRespVO> getMindMap(@RequestParam("id") Long id) {
|
||||
AiMindMapDO mindMap = mindMapService.getMindMap(id);
|
||||
return success(BeanUtils.toBean(mindMap, AiMindMapRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得思维导图分页")
|
||||
@PreAuthorize("@ss.hasPermission('ai:mind-map:query')")
|
||||
|
||||
+9
@@ -78,6 +78,15 @@ public class AiMusicController {
|
||||
return success(BeanUtils.toBean(pageResult, AiMusicRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得音乐")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('ai:music:query')")
|
||||
public CommonResult<AiMusicRespVO> getMusic(@RequestParam("id") Long id) {
|
||||
AiMusicDO music = musicService.getMusic(id);
|
||||
return success(BeanUtils.toBean(music, AiMusicRespVO.class));
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除音乐")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
|
||||
+9
@@ -46,6 +46,15 @@ public class AiWriteController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得写作")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('ai:write:query')")
|
||||
public CommonResult<AiWriteRespVO> getWrite(@RequestParam("id") Long id) {
|
||||
AiWriteDO write = writeService.getWrite(id);
|
||||
return success(BeanUtils.toBean(write, AiWriteRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得写作分页")
|
||||
@PreAuthorize("@ss.hasPermission('ai:write:query')")
|
||||
|
||||
+16
@@ -45,6 +45,14 @@ public interface AiChatMessageService {
|
||||
*/
|
||||
List<AiChatMessageDO> getChatMessageListByConversationId(Long conversationId);
|
||||
|
||||
/**
|
||||
* 获得聊天消息
|
||||
*
|
||||
* @param id 消息编号
|
||||
* @return 聊天消息
|
||||
*/
|
||||
AiChatMessageDO getChatMessage(Long id);
|
||||
|
||||
/**
|
||||
* 删除消息
|
||||
*
|
||||
@@ -68,6 +76,14 @@ public interface AiChatMessageService {
|
||||
*/
|
||||
void deleteChatMessageByAdmin(Long id);
|
||||
|
||||
/**
|
||||
* 获得聊天对话的消息数量
|
||||
*
|
||||
* @param conversationId 对话编号
|
||||
* @return 消息数量
|
||||
*/
|
||||
Integer getChatMessageCount(Long conversationId);
|
||||
|
||||
/**
|
||||
* 获得聊天对话的消息数量 Map
|
||||
*
|
||||
|
||||
+10
@@ -524,6 +524,11 @@ public class AiChatMessageServiceImpl implements AiChatMessageService {
|
||||
return chatMessageMapper.selectListByConversationId(conversationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AiChatMessageDO getChatMessage(Long id) {
|
||||
return chatMessageMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteChatMessage(Long id, Long userId) {
|
||||
// 1. 校验消息存在
|
||||
@@ -557,6 +562,11 @@ public class AiChatMessageServiceImpl implements AiChatMessageService {
|
||||
chatMessageMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getChatMessageCount(Long conversationId) {
|
||||
return chatMessageMapper.selectCount(AiChatMessageDO::getConversationId, conversationId).intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, Integer> getChatMessageCountMap(Collection<Long> conversationIds) {
|
||||
return chatMessageMapper.selectCountMapByConversationId(conversationIds);
|
||||
|
||||
+8
@@ -30,6 +30,14 @@ public interface AiMindMapService {
|
||||
*/
|
||||
void deleteMindMap(Long id);
|
||||
|
||||
/**
|
||||
* 获得思维导图
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 思维导图
|
||||
*/
|
||||
AiMindMapDO getMindMap(Long id);
|
||||
|
||||
/**
|
||||
* 获得思维导图分页
|
||||
*
|
||||
|
||||
+5
@@ -153,6 +153,11 @@ public class AiMindMapServiceImpl implements AiMindMapService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AiMindMapDO getMindMap(Long id) {
|
||||
return mindMapMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<AiMindMapDO> getMindMapPage(AiMindMapPageReqVO pageReqVO) {
|
||||
return mindMapMapper.selectPage(pageReqVO);
|
||||
|
||||
+8
@@ -30,6 +30,14 @@ public interface AiWriteService {
|
||||
*/
|
||||
void deleteWrite(Long id);
|
||||
|
||||
/**
|
||||
* 获得写作
|
||||
*
|
||||
* @param id 编号
|
||||
* @return AI 写作
|
||||
*/
|
||||
AiWriteDO getWrite(Long id);
|
||||
|
||||
/**
|
||||
* 获得写作分页
|
||||
*
|
||||
|
||||
+5
@@ -170,6 +170,11 @@ public class AiWriteServiceImpl implements AiWriteService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AiWriteDO getWrite(Long id) {
|
||||
return writeMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<AiWriteDO> getWritePage(AiWritePageReqVO pageReqVO) {
|
||||
return writeMapper.selectPage(pageReqVO);
|
||||
|
||||
Reference in New Issue
Block a user