feat: add knowledge directory management for documents and FAQs
- Implemented directory validation in Create and Update knowledge document services. - Added directory selection in document and FAQ edit dialogs with a new KnowledgeDirectoryPanel component. - Enhanced API to support fetching, creating, updating, and deleting knowledge directories. - Updated data models to include directory information for knowledge documents and FAQs. - Added translations for directory-related messages in English and Chinese.
This commit is contained in:
@@ -2,6 +2,7 @@ package rag
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"agent-desk/internal/models"
|
||||
"agent-desk/internal/pkg/enums"
|
||||
@@ -18,6 +19,35 @@ func (s *index) loadDocumentByID(documentID int64) (*models.KnowledgeDocument, e
|
||||
return document, nil
|
||||
}
|
||||
|
||||
func loadKnowledgeDirectoryPath(directoryID int64) string {
|
||||
if directoryID <= 0 {
|
||||
return ""
|
||||
}
|
||||
item := repositories.KnowledgeDirectoryRepository.Get(sqls.DB(), directoryID)
|
||||
if item == nil {
|
||||
return ""
|
||||
}
|
||||
if item.ParentID <= 0 {
|
||||
return item.Name
|
||||
}
|
||||
parent := repositories.KnowledgeDirectoryRepository.Get(sqls.DB(), item.ParentID)
|
||||
if parent == nil {
|
||||
return item.Name
|
||||
}
|
||||
return parent.Name + " / " + item.Name
|
||||
}
|
||||
|
||||
func joinKnowledgeSectionPath(parts ...string) string {
|
||||
ret := make([]string, 0, len(parts))
|
||||
for _, item := range parts {
|
||||
item = strings.TrimSpace(item)
|
||||
if item != "" {
|
||||
ret = append(ret, item)
|
||||
}
|
||||
}
|
||||
return strings.Join(ret, " / ")
|
||||
}
|
||||
|
||||
func (s *index) loadFAQByID(faqID int64) (*models.KnowledgeFAQ, error) {
|
||||
faq := repositories.KnowledgeFAQRepository.Get(sqls.DB(), faqID)
|
||||
if faq == nil {
|
||||
|
||||
Reference in New Issue
Block a user