fix(skills): configuration modification

This commit is contained in:
Timebomb2018
2026-02-04 18:06:29 +08:00
parent 161da723b9
commit 71abd16ae7
11 changed files with 184 additions and 91 deletions

View File

@@ -19,6 +19,14 @@ class SkillService:
@staticmethod
def create_skill(db: Session, data: SkillCreate, tenant_id: uuid.UUID) -> Skill:
"""创建技能"""
# 检查同名技能
existing = db.query(Skill).filter(
Skill.tenant_id == tenant_id,
Skill.name == data.name
).first()
if existing:
raise BusinessException(f"技能名称'{data.name}'已存在", BizCode.DUPLICATE_NAME)
skill = SkillRepository.create(db, data, tenant_id)
db.commit()
db.refresh(skill)
@@ -31,6 +39,22 @@ class SkillService:
skill = SkillRepository.get_by_id(db, skill_id, tenant_id)
if not skill:
raise BusinessException(f"技能{skill_id}不存在", BizCode.NOT_FOUND)
# 填充工具详情
tool_service = ToolService(db)
enriched_tools = []
for tool_config in skill.tools:
tool_id = tool_config.get("tool_id")
if tool_id:
tool_info = tool_service.get_tool_info(tool_id, tenant_id)
if tool_info:
enriched_tools.append({
"tool_id": tool_id,
"operation": tool_config.get("operation"),
"tool_info": tool_info
})
skill.tools = enriched_tools
return skill
except (BusinessException, SQLAlchemyError) as e:
db.rollback()