feat(skill): refactor candidateLoader and update loadCandidateSkills to use getSkillByID

This commit is contained in:
mlogclub
2026-04-17 17:23:29 +08:00
parent a601fa707f
commit c396a4a5e3
3 changed files with 9 additions and 9 deletions
+8 -3
View File
@@ -9,11 +9,12 @@ import (
"github.com/mlogclub/simple/sqls"
)
func newCandidateLoader() *candidateLoader {
var newCandidateLoader = func() *candidateLoader {
return &candidateLoader{}
}
type candidateLoader struct{}
type candidateLoader struct {
}
func (l *candidateLoader) findManualSkillDefinition(skillCode string) *models.SkillDefinition {
return repositories.SkillDefinitionRepository.GetByCode(sqls.DB(), skillCode)
@@ -30,7 +31,7 @@ func (l *candidateLoader) loadCandidateSkills(aiAgent *models.AIAgent) []models.
ret := make([]models.SkillDefinition, 0, len(skillIDs))
for _, id := range skillIDs {
// TODO 这里批量查询一下,批量查询返回数据的顺序需要保证和skillIDs一致
skill := repositories.SkillDefinitionRepository.Get(sqls.DB(), id)
skill := l.getSkillByID(id)
if skill == nil || skill.Status != enums.StatusOk {
continue
}
@@ -38,3 +39,7 @@ func (l *candidateLoader) loadCandidateSkills(aiAgent *models.AIAgent) []models.
}
return ret
}
func (l *candidateLoader) getSkillByID(id int64) *models.SkillDefinition {
return repositories.SkillDefinitionRepository.Get(sqls.DB(), id)
}