feat(ai-agent): 在创建和更新智能体时自动设置操作人信息
Some checks failed
Build and Deploy / deploy (push) Has been cancelled

移除 AiAgentSaveReqVO 中 icon、description、systemPrompt、operatorId 和 operatorName 字段的必填校验,改为由服务层自动获取当前登录用户的信息进行填充。
This commit is contained in:
2026-05-01 14:38:30 +08:00
parent 8f8b0a03e4
commit 038f205413
2 changed files with 9 additions and 10 deletions

View File

@@ -35,6 +35,8 @@ public class AiAgentServiceImpl implements AiAgentService {
public Long createAiAgent(AiAgentSaveReqVO createReqVO) {
// 插入
AiAgentDO aiAgent = BeanUtils.toBean(createReqVO, AiAgentDO.class);
aiAgent.setOperatorId(SecurityFrameworkUtils.getLoginUserId());
aiAgent.setOperatorName(String.valueOf(SecurityFrameworkUtils.getLoginUserNickname()));
aiAgentMapper.insert(aiAgent);
// 返回
@@ -47,6 +49,8 @@ public class AiAgentServiceImpl implements AiAgentService {
validateAiAgentExists(updateReqVO.getId());
// 更新
AiAgentDO updateObj = BeanUtils.toBean(updateReqVO, AiAgentDO.class);
updateObj.setOperatorId(SecurityFrameworkUtils.getLoginUserId());
updateObj.setOperatorName(String.valueOf(SecurityFrameworkUtils.getLoginUserNickname()));
aiAgentMapper.updateById(updateObj);
}

View File

@@ -19,20 +19,17 @@ public class AiAgentSaveReqVO {
@NotEmpty(message = "智能体名称不能为空")
private String agentName;
@Schema(description = "图标URL", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "图标URL不能为空")
@Schema(description = "图标URL", example = "https://example.com/icon.png")
private String icon;
@Schema(description = "状态(0-禁用 1-启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "状态(0-禁用 1-启用)不能为空")
private Integer status;
@Schema(description = "设定描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对")
@NotEmpty(message = "设定描述不能为空")
@Schema(description = "设定描述", example = "你说的对")
private String description;
@Schema(description = "预置提示词", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "预置提示词不能为空")
@Schema(description = "预置提示词")
private String systemPrompt;
@Schema(description = "备注", example = "你说的对")
@@ -41,12 +38,10 @@ public class AiAgentSaveReqVO {
@Schema(description = "分类名称(中文)", example = "文案创作")
private String categoryName;
@Schema(description = "操作人用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6593")
@NotNull(message = "操作人用户编号不能为空")
@Schema(description = "操作人用户编号", example = "6593")
private Long operatorId;
@Schema(description = "操作人账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
@NotEmpty(message = "操作人账号不能为空")
@Schema(description = "操作人账号", example = "赵六")
private String operatorName;
}