refactor: replace skill code with skill ID across the application

- Updated skill handling to use skill IDs instead of skill codes in various components, services, and models.
- Modified tests to reflect changes in skill identification.
- Removed references to skill codes in favor of skill IDs for consistency and clarity.
- Updated localization files to remove skill code references and adjust error messages accordingly.
This commit is contained in:
mlogclub
2026-06-20 20:42:07 +08:00
parent 39c648f3c1
commit 541e4c5874
49 changed files with 258 additions and 341 deletions
@@ -76,10 +76,6 @@ func (s *skillDefinitionService) Delete(id int64) {
repositories.SkillDefinitionRepository.Delete(sqls.DB(), id)
}
func (s *skillDefinitionService) GetByCode(code string) *models.SkillDefinition {
return repositories.SkillDefinitionRepository.GetByCode(sqls.DB(), code)
}
func (s *skillDefinitionService) GetByIDs(ids []int64) map[int64]models.SkillDefinition {
return repositories.SkillDefinitionRepository.GetByIDs(sqls.DB(), ids)
}
@@ -92,11 +88,7 @@ func (s *skillDefinitionService) CreateSkillDefinition(req request.CreateSkillDe
if err != nil {
return nil, err
}
if s.Take("code = ?", normalized.Code) != nil {
return nil, errorsx.InvalidParamI18n("error.e0058")
}
item := &models.SkillDefinition{
Code: normalized.Code,
Name: normalized.Name,
Description: normalized.Description,
Instruction: normalized.Instruction,
@@ -127,11 +119,7 @@ func (s *skillDefinitionService) UpdateSkillDefinition(req request.UpdateSkillDe
if err != nil {
return err
}
if exists := s.Take("code = ? AND id <> ?", normalized.Code, req.ID); exists != nil {
return errorsx.InvalidParamI18n("error.e0058")
}
return repositories.SkillDefinitionRepository.Updates(sqls.DB(), req.ID, map[string]any{
"code": normalized.Code,
"name": normalized.Name,
"description": normalized.Description,
"instruction": normalized.Instruction,
@@ -146,15 +134,11 @@ func (s *skillDefinitionService) UpdateSkillDefinition(req request.UpdateSkillDe
func (s *skillDefinitionService) normalizeSkillDefinitionRequest(req request.CreateSkillDefinitionRequest) (*request.CreateSkillDefinitionRequest, error) {
normalized := &request.CreateSkillDefinitionRequest{
Code: strings.TrimSpace(req.Code),
Name: strings.TrimSpace(req.Name),
Description: strings.TrimSpace(req.Description),
Instruction: strings.TrimSpace(req.Instruction),
Remark: strings.TrimSpace(req.Remark),
}
if normalized.Code == "" {
return nil, errorsx.InvalidParamI18n("error.e0057")
}
if normalized.Name == "" {
return nil, errorsx.InvalidParamI18n("error.e0055")
}
+1 -1
View File
@@ -24,7 +24,7 @@ func (s *skillRuntimeService) DebugRun(ctx context.Context, req request.SkillDeb
if req.AIAgentID <= 0 {
return nil, errorsx.InvalidParamI18n("error.e0061")
}
if strings.TrimSpace(req.SkillCode) == "" {
if req.SkillDefinitionID <= 0 {
return nil, errorsx.InvalidParamI18n("error.e0071")
}
if strings.TrimSpace(req.UserMessage) == "" {