feat(skill): optimize loadCandidateSkills to use batch retrieval for skill definitions

This commit is contained in:
mlogclub
2026-04-17 17:27:33 +08:00
parent c396a4a5e3
commit 81056a61a1
2 changed files with 18 additions and 12 deletions
@@ -103,3 +103,18 @@ func (r *skillDefinitionRepository) Delete(db *gorm.DB, id int64) {
func (r *skillDefinitionRepository) GetByCode(db *gorm.DB, code string) *models.SkillDefinition {
return r.FindOne(db, sqls.NewCnd().Where("code = ?", code))
}
func (r *skillDefinitionRepository) GetByIDs(db *gorm.DB, ids []int64) map[int64]models.SkillDefinition {
if len(ids) == 0 {
return nil
}
list := r.Find(db, sqls.NewCnd().Where("id IN (?)", ids))
if len(list) == 0 {
return nil
}
result := make(map[int64]models.SkillDefinition, len(list))
for _, item := range list {
result[item.ID] = item
}
return result
}