Commit cec8cc7a2b2dfc925ca660fb2c929a06f1cd6f56
1 parent
a0b3bd32
优化:chat角色 - 修改可见性
Showing
5 changed files
with
64 additions
and
15 deletions
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatRoleController.java
| ... | ... | @@ -48,16 +48,17 @@ public class ChatRoleController { |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | @Operation(summary = "chat角色 - 修改可见性") |
| 51 | - @PostMapping("/role/update-visibility") | |
| 52 | - public CommonResult<Void> updateVisibility(@Validated @RequestBody ChatRoleUpdateVisibilityReq req) { | |
| 53 | - chatRoleService.updateVisibility(req); | |
| 51 | + @PostMapping("/role/{id}/update-visibility") | |
| 52 | + public CommonResult<Void> updateVisibility(@PathVariable("id") Long id, | |
| 53 | + @Validated @RequestBody ChatRoleUpdateVisibilityReq req) { | |
| 54 | + chatRoleService.updateVisibility(id, req); | |
| 54 | 55 | return CommonResult.success(null); |
| 55 | 56 | } |
| 56 | 57 | |
| 57 | - @Operation(summary = "chat角色 - 修改可见性") | |
| 58 | - @DeleteMapping("/role") | |
| 59 | - public CommonResult<Void> delete(@RequestParam("chatRoleId") Long chatRoleId) { | |
| 60 | - chatRoleService.delete(chatRoleId); | |
| 58 | + @Operation(summary = "chat角色 - 删除") | |
| 59 | + @DeleteMapping("/role/{id}") | |
| 60 | + public CommonResult<Void> delete(@PathVariable("id") Long id) { | |
| 61 | + chatRoleService.delete(id); | |
| 61 | 62 | return CommonResult.success(null); |
| 62 | 63 | } |
| 63 | 64 | } | ... | ... |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatRoleService.java
| ... | ... | @@ -42,9 +42,10 @@ public interface ChatRoleService { |
| 42 | 42 | /** |
| 43 | 43 | * chat角色 - 修改可见性 |
| 44 | 44 | * |
| 45 | + * @param id | |
| 45 | 46 | * @param req |
| 46 | 47 | */ |
| 47 | - void updateVisibility(ChatRoleUpdateVisibilityReq req); | |
| 48 | + void updateVisibility(Long id, ChatRoleUpdateVisibilityReq req); | |
| 48 | 49 | |
| 49 | 50 | /** |
| 50 | 51 | * chat角色 - 删除 | ... | ... |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/ChatRoleServiceImpl.java
| ... | ... | @@ -82,14 +82,14 @@ public class ChatRoleServiceImpl implements ChatRoleService { |
| 82 | 82 | |
| 83 | 83 | |
| 84 | 84 | @Override |
| 85 | - public void updateVisibility(ChatRoleUpdateVisibilityReq req) { | |
| 85 | + public void updateVisibility(Long id, ChatRoleUpdateVisibilityReq req) { | |
| 86 | 86 | // 转换enum,并校验enum |
| 87 | 87 | ChatRoleVisibilityEnum.valueOfType(req.getVisibility()); |
| 88 | 88 | // 检查角色是否存在 |
| 89 | - validateChatRoleExists(req.getId()); | |
| 89 | + validateChatRoleExists(id); | |
| 90 | 90 | // 更新 |
| 91 | 91 | aiChatRoleMapper.updateById(new AiChatRoleDO() |
| 92 | - .setId(req.getId()) | |
| 92 | + .setId(id) | |
| 93 | 93 | .setVisibility(req.getVisibility()) |
| 94 | 94 | ); |
| 95 | 95 | } | ... | ... |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleUpdateVisibilityReq.java
| ... | ... | @@ -17,10 +17,6 @@ import lombok.experimental.Accessors; |
| 17 | 17 | public class ChatRoleUpdateVisibilityReq extends PageParam { |
| 18 | 18 | |
| 19 | 19 | @NotNull |
| 20 | - @Schema(description = "编号") | |
| 21 | - private Long id; | |
| 22 | - | |
| 23 | - @NotNull | |
| 24 | 20 | @Schema(description = "发布状态,0表示仅自己可见,1表示公开,2表示禁用") |
| 25 | 21 | private String visibility; |
| 26 | 22 | } | ... | ... |
yudao-module-ai/yudao-module-ai-biz/src/main/resources/http/chat-role.http
0 → 100644
| 1 | + | |
| 2 | +### chat角色 - list | |
| 3 | +GET {{baseUrl}}/ai/chat/role/list?pageNo=1&pageSize=20&search= | |
| 4 | +Authorization: {{token}} | |
| 5 | + | |
| 6 | + | |
| 7 | +### chat add | |
| 8 | +PUT {{baseUrl}}/ai/chat/role | |
| 9 | +Content-Type: application/json | |
| 10 | +Authorization: {{token}} | |
| 11 | + | |
| 12 | +{ | |
| 13 | + "modelId": 1, | |
| 14 | + "roleName": "小红书写作v1", | |
| 15 | + "roleIntroduce": "采用gpt3.5模型,拥有小红书优质作者写作经验。", | |
| 16 | + "roleSource": "system", | |
| 17 | + "classify": "writing", | |
| 18 | + "visibility": "public", | |
| 19 | + "topK": 0.2, | |
| 20 | + "topP": 0.4, | |
| 21 | + "temperature": 0.7 | |
| 22 | +} | |
| 23 | + | |
| 24 | + | |
| 25 | +### chat update | |
| 26 | +POST {{baseUrl}}/ai/chat/role/1 | |
| 27 | +Content-Type: application/json | |
| 28 | +Authorization: {{token}} | |
| 29 | + | |
| 30 | +{ | |
| 31 | + "modelId": 1, | |
| 32 | + "roleName": "小红书写作v1---hh😄", | |
| 33 | + "roleIntroduce": "采用gpt3.5模型,拥有小红书优质作者写作经验。", | |
| 34 | + "roleSource": "system", | |
| 35 | + "classify": "writing", | |
| 36 | + "visibility": "public", | |
| 37 | + "topK": 0.2, | |
| 38 | + "topP": 0.4, | |
| 39 | + "temperature": 0.7 | |
| 40 | +} | |
| 41 | + | |
| 42 | +### chat update | |
| 43 | +POST {{baseUrl}}/ai/chat/role/1/update-visibility | |
| 44 | +Content-Type: application/json | |
| 45 | +Authorization: {{token}} | |
| 46 | + | |
| 47 | +{ | |
| 48 | + "visibility": "private" | |
| 49 | +} | |
| 50 | + | |
| 51 | + | ... | ... |