优化:chat角色 - 修改可见性

This commit is contained in:
cherishsince 2024-04-24 19:38:19 +08:00
parent a0b3bd32b0
commit cec8cc7a2b
5 changed files with 64 additions and 15 deletions

View File

@ -48,16 +48,17 @@ public class ChatRoleController {
}
@Operation(summary = "chat角色 - 修改可见性")
@PostMapping("/role/update-visibility")
public CommonResult<Void> updateVisibility(@Validated @RequestBody ChatRoleUpdateVisibilityReq req) {
chatRoleService.updateVisibility(req);
@PostMapping("/role/{id}/update-visibility")
public CommonResult<Void> updateVisibility(@PathVariable("id") Long id,
@Validated @RequestBody ChatRoleUpdateVisibilityReq req) {
chatRoleService.updateVisibility(id, req);
return CommonResult.success(null);
}
@Operation(summary = "chat角色 - 修改可见性")
@DeleteMapping("/role")
public CommonResult<Void> delete(@RequestParam("chatRoleId") Long chatRoleId) {
chatRoleService.delete(chatRoleId);
@Operation(summary = "chat角色 - 删除")
@DeleteMapping("/role/{id}")
public CommonResult<Void> delete(@PathVariable("id") Long id) {
chatRoleService.delete(id);
return CommonResult.success(null);
}
}

View File

@ -42,9 +42,10 @@ public interface ChatRoleService {
/**
* chat角色 - 修改可见性
*
* @param id
* @param req
*/
void updateVisibility(ChatRoleUpdateVisibilityReq req);
void updateVisibility(Long id, ChatRoleUpdateVisibilityReq req);
/**
* chat角色 - 删除

View File

@ -82,14 +82,14 @@ public class ChatRoleServiceImpl implements ChatRoleService {
@Override
public void updateVisibility(ChatRoleUpdateVisibilityReq req) {
public void updateVisibility(Long id, ChatRoleUpdateVisibilityReq req) {
// 转换enum并校验enum
ChatRoleVisibilityEnum.valueOfType(req.getVisibility());
// 检查角色是否存在
validateChatRoleExists(req.getId());
validateChatRoleExists(id);
// 更新
aiChatRoleMapper.updateById(new AiChatRoleDO()
.setId(req.getId())
.setId(id)
.setVisibility(req.getVisibility())
);
}

View File

@ -16,10 +16,6 @@ import lombok.experimental.Accessors;
@Accessors(chain = true)
public class ChatRoleUpdateVisibilityReq extends PageParam {
@NotNull
@Schema(description = "编号")
private Long id;
@NotNull
@Schema(description = "发布状态0表示仅自己可见1表示公开2表示禁用")
private String visibility;

View File

@ -0,0 +1,51 @@
### chat角色 - list
GET {{baseUrl}}/ai/chat/role/list?pageNo=1&pageSize=20&search=
Authorization: {{token}}
### chat add
PUT {{baseUrl}}/ai/chat/role
Content-Type: application/json
Authorization: {{token}}
{
"modelId": 1,
"roleName": "小红书写作v1",
"roleIntroduce": "采用gpt3.5模型,拥有小红书优质作者写作经验。",
"roleSource": "system",
"classify": "writing",
"visibility": "public",
"topK": 0.2,
"topP": 0.4,
"temperature": 0.7
}
### chat update
POST {{baseUrl}}/ai/chat/role/1
Content-Type: application/json
Authorization: {{token}}
{
"modelId": 1,
"roleName": "小红书写作v1---hh😄",
"roleIntroduce": "采用gpt3.5模型,拥有小红书优质作者写作经验。",
"roleSource": "system",
"classify": "writing",
"visibility": "public",
"topK": 0.2,
"topP": 0.4,
"temperature": 0.7
}
### chat update
POST {{baseUrl}}/ai/chat/role/1/update-visibility
Content-Type: application/json
Authorization: {{token}}
{
"visibility": "private"
}