Commit ef9f43e77e7e4a53a68585e124ef504625122861

Authored by YunaiV
1 parent 2ef66566

feat(ai): 增加更多 get 获取详情接口

yudao-module-ai/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/AiChatConversationController.java
@@ -106,6 +106,20 @@ public class AiChatConversationController { @@ -106,6 +106,20 @@ public class AiChatConversationController {
106 conversation -> conversation.setMessageCount(messageCountMap.getOrDefault(conversation.getId(), 0)))); 106 conversation -> conversation.setMessageCount(messageCountMap.getOrDefault(conversation.getId(), 0))));
107 } 107 }
108 108
  109 + @GetMapping("/get")
  110 + @Operation(summary = "获得对话", description = "用于【对话管理】菜单")
  111 + @Parameter(name = "id", required = true, description = "对话编号", example = "1024")
  112 + @PreAuthorize("@ss.hasPermission('ai:chat-conversation:query')")
  113 + @TransMethodResult
  114 + public CommonResult<AiChatConversationRespVO> getChatConversation(@RequestParam("id") Long id) {
  115 + AiChatConversationDO conversation = chatConversationService.getChatConversation(id);
  116 + AiChatConversationRespVO respVO = BeanUtils.toBean(conversation, AiChatConversationRespVO.class);
  117 + if (respVO != null) {
  118 + respVO.setMessageCount(chatMessageService.getChatMessageCount(id));
  119 + }
  120 + return success(respVO);
  121 + }
  122 +
109 @Operation(summary = "管理员删除对话") 123 @Operation(summary = "管理员删除对话")
110 @DeleteMapping("/delete-by-admin") 124 @DeleteMapping("/delete-by-admin")
111 @Parameter(name = "id", required = true, description = "对话编号", example = "1024") 125 @Parameter(name = "id", required = true, description = "对话编号", example = "1024")
yudao-module-ai/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/AiChatMessageController.java
@@ -131,7 +131,7 @@ public class AiChatMessageController { @@ -131,7 +131,7 @@ public class AiChatMessageController {
131 131
132 @GetMapping("/page") 132 @GetMapping("/page")
133 @Operation(summary = "获得消息分页", description = "用于【对话管理】菜单") 133 @Operation(summary = "获得消息分页", description = "用于【对话管理】菜单")
134 - @PreAuthorize("@ss.hasPermission('ai:chat-conversation:query')") 134 + @PreAuthorize("@ss.hasPermission('ai:chat-message:query')")
135 public CommonResult<PageResult<AiChatMessageRespVO>> getChatMessagePage(AiChatMessagePageReqVO pageReqVO) { 135 public CommonResult<PageResult<AiChatMessageRespVO>> getChatMessagePage(AiChatMessagePageReqVO pageReqVO) {
136 PageResult<AiChatMessageDO> pageResult = chatMessageService.getChatMessagePage(pageReqVO); 136 PageResult<AiChatMessageDO> pageResult = chatMessageService.getChatMessagePage(pageReqVO);
137 if (CollUtil.isEmpty(pageResult.getList())) { 137 if (CollUtil.isEmpty(pageResult.getList())) {
@@ -145,6 +145,20 @@ public class AiChatMessageController { @@ -145,6 +145,20 @@ public class AiChatMessageController {
145 role -> respVO.setRoleName(role.getName())))); 145 role -> respVO.setRoleName(role.getName()))));
146 } 146 }
147 147
  148 + @GetMapping("/get")
  149 + @Operation(summary = "获得消息", description = "用于【对话管理】菜单")
  150 + @Parameter(name = "id", required = true, description = "消息编号", example = "1024")
  151 + @PreAuthorize("@ss.hasPermission('ai:chat-message:query')")
  152 + public CommonResult<AiChatMessageRespVO> getChatMessage(@RequestParam("id") Long id) {
  153 + AiChatMessageDO message = chatMessageService.getChatMessage(id);
  154 + AiChatMessageRespVO respVO = BeanUtils.toBean(message, AiChatMessageRespVO.class);
  155 + if (respVO != null && respVO.getRoleId() != null) {
  156 + AiChatRoleDO role = chatRoleService.getChatRole(respVO.getRoleId());
  157 + respVO.setRoleName(role != null ? role.getName() : null);
  158 + }
  159 + return success(respVO);
  160 + }
  161 +
148 @Operation(summary = "管理员删除消息") 162 @Operation(summary = "管理员删除消息")
149 @DeleteMapping("/delete-by-admin") 163 @DeleteMapping("/delete-by-admin")
150 @Parameter(name = "id", required = true, description = "消息编号", example = "1024") 164 @Parameter(name = "id", required = true, description = "消息编号", example = "1024")
yudao-module-ai/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java
@@ -119,6 +119,15 @@ public class AiImageController { @@ -119,6 +119,15 @@ public class AiImageController {
119 return success(BeanUtils.toBean(pageResult, AiImageRespVO.class)); 119 return success(BeanUtils.toBean(pageResult, AiImageRespVO.class));
120 } 120 }
121 121
  122 + @GetMapping("/get")
  123 + @Operation(summary = "获得绘画")
  124 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  125 + @PreAuthorize("@ss.hasPermission('ai:image:query')")
  126 + public CommonResult<AiImageRespVO> getImage(@RequestParam("id") Long id) {
  127 + AiImageDO image = imageService.getImage(id);
  128 + return success(BeanUtils.toBean(image, AiImageRespVO.class));
  129 + }
  130 +
122 @PutMapping("/update") 131 @PutMapping("/update")
123 @Operation(summary = "更新绘画") 132 @Operation(summary = "更新绘画")
124 @PreAuthorize("@ss.hasPermission('ai:image:update')") 133 @PreAuthorize("@ss.hasPermission('ai:image:update')")
@@ -136,4 +145,4 @@ public class AiImageController { @@ -136,4 +145,4 @@ public class AiImageController {
136 return success(true); 145 return success(true);
137 } 146 }
138 147
139 -}  
140 \ No newline at end of file 148 \ No newline at end of file
  149 +}
yudao-module-ai/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/mindmap/AiMindMapController.java
@@ -46,6 +46,15 @@ public class AiMindMapController { @@ -46,6 +46,15 @@ public class AiMindMapController {
46 return success(true); 46 return success(true);
47 } 47 }
48 48
  49 + @GetMapping("/get")
  50 + @Operation(summary = "获得思维导图")
  51 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  52 + @PreAuthorize("@ss.hasPermission('ai:mind-map:query')")
  53 + public CommonResult<AiMindMapRespVO> getMindMap(@RequestParam("id") Long id) {
  54 + AiMindMapDO mindMap = mindMapService.getMindMap(id);
  55 + return success(BeanUtils.toBean(mindMap, AiMindMapRespVO.class));
  56 + }
  57 +
49 @GetMapping("/page") 58 @GetMapping("/page")
50 @Operation(summary = "获得思维导图分页") 59 @Operation(summary = "获得思维导图分页")
51 @PreAuthorize("@ss.hasPermission('ai:mind-map:query')") 60 @PreAuthorize("@ss.hasPermission('ai:mind-map:query')")
yudao-module-ai/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/music/AiMusicController.java
@@ -78,6 +78,15 @@ public class AiMusicController { @@ -78,6 +78,15 @@ public class AiMusicController {
78 return success(BeanUtils.toBean(pageResult, AiMusicRespVO.class)); 78 return success(BeanUtils.toBean(pageResult, AiMusicRespVO.class));
79 } 79 }
80 80
  81 + @GetMapping("/get")
  82 + @Operation(summary = "获得音乐")
  83 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  84 + @PreAuthorize("@ss.hasPermission('ai:music:query')")
  85 + public CommonResult<AiMusicRespVO> getMusic(@RequestParam("id") Long id) {
  86 + AiMusicDO music = musicService.getMusic(id);
  87 + return success(BeanUtils.toBean(music, AiMusicRespVO.class));
  88 + }
  89 +
81 @DeleteMapping("/delete") 90 @DeleteMapping("/delete")
82 @Operation(summary = "删除音乐") 91 @Operation(summary = "删除音乐")
83 @Parameter(name = "id", description = "编号", required = true) 92 @Parameter(name = "id", description = "编号", required = true)
yudao-module-ai/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/write/AiWriteController.java
@@ -46,6 +46,15 @@ public class AiWriteController { @@ -46,6 +46,15 @@ public class AiWriteController {
46 return success(true); 46 return success(true);
47 } 47 }
48 48
  49 + @GetMapping("/get")
  50 + @Operation(summary = "获得写作")
  51 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  52 + @PreAuthorize("@ss.hasPermission('ai:write:query')")
  53 + public CommonResult<AiWriteRespVO> getWrite(@RequestParam("id") Long id) {
  54 + AiWriteDO write = writeService.getWrite(id);
  55 + return success(BeanUtils.toBean(write, AiWriteRespVO.class));
  56 + }
  57 +
49 @GetMapping("/page") 58 @GetMapping("/page")
50 @Operation(summary = "获得写作分页") 59 @Operation(summary = "获得写作分页")
51 @PreAuthorize("@ss.hasPermission('ai:write:query')") 60 @PreAuthorize("@ss.hasPermission('ai:write:query')")
yudao-module-ai/src/main/java/cn/iocoder/yudao/module/ai/service/chat/AiChatMessageService.java
@@ -46,6 +46,14 @@ public interface AiChatMessageService { @@ -46,6 +46,14 @@ public interface AiChatMessageService {
46 List<AiChatMessageDO> getChatMessageListByConversationId(Long conversationId); 46 List<AiChatMessageDO> getChatMessageListByConversationId(Long conversationId);
47 47
48 /** 48 /**
  49 + * 获得聊天消息
  50 + *
  51 + * @param id 消息编号
  52 + * @return 聊天消息
  53 + */
  54 + AiChatMessageDO getChatMessage(Long id);
  55 +
  56 + /**
49 * 删除消息 57 * 删除消息
50 * 58 *
51 * @param id 消息编号 59 * @param id 消息编号
@@ -69,6 +77,14 @@ public interface AiChatMessageService { @@ -69,6 +77,14 @@ public interface AiChatMessageService {
69 void deleteChatMessageByAdmin(Long id); 77 void deleteChatMessageByAdmin(Long id);
70 78
71 /** 79 /**
  80 + * 获得聊天对话的消息数量
  81 + *
  82 + * @param conversationId 对话编号
  83 + * @return 消息数量
  84 + */
  85 + Integer getChatMessageCount(Long conversationId);
  86 +
  87 + /**
72 * 获得聊天对话的消息数量 Map 88 * 获得聊天对话的消息数量 Map
73 * 89 *
74 * @param conversationIds 对话编号数组 90 * @param conversationIds 对话编号数组
yudao-module-ai/src/main/java/cn/iocoder/yudao/module/ai/service/chat/AiChatMessageServiceImpl.java
@@ -525,6 +525,11 @@ public class AiChatMessageServiceImpl implements AiChatMessageService { @@ -525,6 +525,11 @@ public class AiChatMessageServiceImpl implements AiChatMessageService {
525 } 525 }
526 526
527 @Override 527 @Override
  528 + public AiChatMessageDO getChatMessage(Long id) {
  529 + return chatMessageMapper.selectById(id);
  530 + }
  531 +
  532 + @Override
528 public void deleteChatMessage(Long id, Long userId) { 533 public void deleteChatMessage(Long id, Long userId) {
529 // 1. 校验消息存在 534 // 1. 校验消息存在
530 AiChatMessageDO message = chatMessageMapper.selectById(id); 535 AiChatMessageDO message = chatMessageMapper.selectById(id);
@@ -558,6 +563,11 @@ public class AiChatMessageServiceImpl implements AiChatMessageService { @@ -558,6 +563,11 @@ public class AiChatMessageServiceImpl implements AiChatMessageService {
558 } 563 }
559 564
560 @Override 565 @Override
  566 + public Integer getChatMessageCount(Long conversationId) {
  567 + return chatMessageMapper.selectCount(AiChatMessageDO::getConversationId, conversationId).intValue();
  568 + }
  569 +
  570 + @Override
561 public Map<Long, Integer> getChatMessageCountMap(Collection<Long> conversationIds) { 571 public Map<Long, Integer> getChatMessageCountMap(Collection<Long> conversationIds) {
562 return chatMessageMapper.selectCountMapByConversationId(conversationIds); 572 return chatMessageMapper.selectCountMapByConversationId(conversationIds);
563 } 573 }
yudao-module-ai/src/main/java/cn/iocoder/yudao/module/ai/service/mindmap/AiMindMapService.java
@@ -31,6 +31,14 @@ public interface AiMindMapService { @@ -31,6 +31,14 @@ public interface AiMindMapService {
31 void deleteMindMap(Long id); 31 void deleteMindMap(Long id);
32 32
33 /** 33 /**
  34 + * 获得思维导图
  35 + *
  36 + * @param id 编号
  37 + * @return 思维导图
  38 + */
  39 + AiMindMapDO getMindMap(Long id);
  40 +
  41 + /**
34 * 获得思维导图分页 42 * 获得思维导图分页
35 * 43 *
36 * @param pageReqVO 分页查询 44 * @param pageReqVO 分页查询
yudao-module-ai/src/main/java/cn/iocoder/yudao/module/ai/service/mindmap/AiMindMapServiceImpl.java
@@ -154,6 +154,11 @@ public class AiMindMapServiceImpl implements AiMindMapService { @@ -154,6 +154,11 @@ public class AiMindMapServiceImpl implements AiMindMapService {
154 } 154 }
155 155
156 @Override 156 @Override
  157 + public AiMindMapDO getMindMap(Long id) {
  158 + return mindMapMapper.selectById(id);
  159 + }
  160 +
  161 + @Override
157 public PageResult<AiMindMapDO> getMindMapPage(AiMindMapPageReqVO pageReqVO) { 162 public PageResult<AiMindMapDO> getMindMapPage(AiMindMapPageReqVO pageReqVO) {
158 return mindMapMapper.selectPage(pageReqVO); 163 return mindMapMapper.selectPage(pageReqVO);
159 } 164 }
yudao-module-ai/src/main/java/cn/iocoder/yudao/module/ai/service/write/AiWriteService.java
@@ -31,6 +31,14 @@ public interface AiWriteService { @@ -31,6 +31,14 @@ public interface AiWriteService {
31 void deleteWrite(Long id); 31 void deleteWrite(Long id);
32 32
33 /** 33 /**
  34 + * 获得写作
  35 + *
  36 + * @param id 编号
  37 + * @return AI 写作
  38 + */
  39 + AiWriteDO getWrite(Long id);
  40 +
  41 + /**
34 * 获得写作分页 42 * 获得写作分页
35 * 43 *
36 * @param pageReqVO 分页查询 44 * @param pageReqVO 分页查询
yudao-module-ai/src/main/java/cn/iocoder/yudao/module/ai/service/write/AiWriteServiceImpl.java
@@ -171,6 +171,11 @@ public class AiWriteServiceImpl implements AiWriteService { @@ -171,6 +171,11 @@ public class AiWriteServiceImpl implements AiWriteService {
171 } 171 }
172 172
173 @Override 173 @Override
  174 + public AiWriteDO getWrite(Long id) {
  175 + return writeMapper.selectById(id);
  176 + }
  177 +
  178 + @Override
174 public PageResult<AiWriteDO> getWritePage(AiWritePageReqVO pageReqVO) { 179 public PageResult<AiWriteDO> getWritePage(AiWritePageReqVO pageReqVO) {
175 return writeMapper.selectPage(pageReqVO); 180 return writeMapper.selectPage(pageReqVO);
176 } 181 }