feat: 新增FAQ条目批量更新排除功能,支持在ByTag操作中排除指定ID列表

This commit is contained in:
wizardchen
2025-12-25 10:41:41 +08:00
committed by lyingbug
parent 557081c8f8
commit 87ead9dec4
5 changed files with 18 additions and 4 deletions
+10
View File
@@ -569,6 +569,7 @@ func (r *chunkRepository) UpdateChunkFieldsByTagID(
isEnabled *bool,
setFlags types.ChunkFlags,
clearFlags types.ChunkFlags,
excludeIDs []string,
) ([]string, error) {
// First, get the IDs of chunks that will be affected (for is_enabled sync)
var affectedIDs []string
@@ -583,6 +584,11 @@ func (r *chunkRepository) UpdateChunkFieldsByTagID(
} else {
query = query.Where("tag_id = ?", tagID)
}
if len(excludeIDs) > 0 {
query = query.Where("id NOT IN ?", excludeIDs)
}
// Only get chunks that need to change
query = query.Where("is_enabled != ?", *isEnabled)
if err := query.Find(&chunks).Error; err != nil {
@@ -612,6 +618,10 @@ func (r *chunkRepository) UpdateChunkFieldsByTagID(
query = query.Where("tag_id = ?", tagID)
}
if len(excludeIDs) > 0 {
query = query.Where("id NOT IN ?", excludeIDs)
}
// Handle flags update
if setFlags != 0 || clearFlags != 0 {
flagsExpr := "flags"
+1 -1
View File
@@ -3570,7 +3570,7 @@ func (s *knowledgeService) UpdateFAQEntryFieldsBatch(ctx context.Context,
// Update all chunks with this tag
affectedIDs, err := s.chunkRepo.UpdateChunkFieldsByTagID(
ctx, tenantID, kb.ID, tagID,
update.IsEnabled, setFlags, clearFlags,
update.IsEnabled, setFlags, clearFlags, req.ExcludeIDs,
)
if err != nil {
return err