refactor: streamline document and FAQ index removal methods and enhance knowledge base deletion logic

This commit is contained in:
mlogclub
2026-06-02 11:25:30 +08:00
parent 5c4d486df0
commit abedafe911
13 changed files with 215 additions and 58 deletions
@@ -1,7 +1,10 @@
package repositories
import (
"strconv"
"agent-desk/internal/models"
"agent-desk/internal/pkg/enums"
"agent-desk/internal/pkg/httpx/params"
@@ -109,3 +112,16 @@ func (r *aIAgentRepository) FindByIds(db *gorm.DB, ids []int64) []models.AIAgent
db.Where("id IN ?", ids).Find(&list)
return list
}
func (r *aIAgentRepository) FindByKnowledgeBaseID(db *gorm.DB, knowledgeBaseID int64) (list []models.AIAgent) {
id := strconv.FormatInt(knowledgeBaseID, 10)
db.Where(
"(knowledge_ids = ? OR knowledge_ids LIKE ? OR knowledge_ids LIKE ? OR knowledge_ids LIKE ?) AND status <> ?",
id,
id+",%",
"%,"+id,
"%,"+id+",%",
enums.StatusDeleted,
).Find(&list)
return
}