541e4c5874
- 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.
37 lines
974 B
Go
37 lines
974 B
Go
package skills
|
|
|
|
import (
|
|
"agent-desk/internal/models"
|
|
"agent-desk/internal/pkg/enums"
|
|
"agent-desk/internal/pkg/utils"
|
|
"agent-desk/internal/repositories"
|
|
|
|
"github.com/mlogclub/simple/sqls"
|
|
)
|
|
|
|
var newCandidateLoader = func() *candidateLoader {
|
|
return &candidateLoader{}
|
|
}
|
|
|
|
type candidateLoader struct {
|
|
}
|
|
|
|
func (l *candidateLoader) findManualSkillDefinition(skillDefinitionID int64) *models.SkillDefinition {
|
|
if skillDefinitionID <= 0 {
|
|
return nil
|
|
}
|
|
return repositories.SkillDefinitionRepository.Get(sqls.DB(), skillDefinitionID)
|
|
}
|
|
|
|
func (l *candidateLoader) loadCandidateSkills(aiAgent models.AIAgent) []models.SkillDefinition {
|
|
skillIDs := utils.SplitInt64s(aiAgent.SkillIDs)
|
|
skills := repositories.SkillDefinitionRepository.GetByIDs(sqls.DB(), skillIDs)
|
|
ret := make([]models.SkillDefinition, 0, len(skillIDs))
|
|
for _, id := range skillIDs {
|
|
if skill, ok := skills[id]; ok && skill.Status == enums.StatusOk {
|
|
ret = append(ret, skill)
|
|
}
|
|
}
|
|
return ret
|
|
}
|