feat: 新增FAQ条目批量更新排除功能,支持在ByTag操作中排除指定ID列表
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user