feat: add ListChunksByParentIDs method and enhance chunk merging logic

- Implemented ListChunksByParentIDs in chunkRepository to retrieve chunks based on multiple parent IDs, improving data retrieval efficiency.
- Enhanced the chunk merging logic in PluginMerge to better handle overlapping chunks and collect merged ImageInfo for parent chunks.
- Updated the ChunkRepository interface to include the new ListChunksByParentIDs method, ensuring consistency across the application.

These changes optimize chunk management and improve the handling of image information during merges, enhancing overall application functionality.
This commit is contained in:
wizardchen
2026-03-05 17:25:07 +08:00
committed by lyingbug
parent 4ddc468fea
commit 927e5d4750
3 changed files with 136 additions and 16 deletions
+17
View File
@@ -246,6 +246,23 @@ func (r *chunkRepository) ListChunkByParentID(
return chunks, nil
}
func (r *chunkRepository) ListChunksByParentIDs(
ctx context.Context,
tenantID uint64,
parentIDs []string,
) ([]*types.Chunk, error) {
if len(parentIDs) == 0 {
return nil, nil
}
var chunks []*types.Chunk
if err := r.db.WithContext(ctx).
Where("tenant_id = ? AND parent_chunk_id IN ?", tenantID, parentIDs).
Find(&chunks).Error; err != nil {
return nil, err
}
return chunks, nil
}
// UpdateChunk updates a chunk using GORM Save, which updates ALL fields
// except SeqID (auto-increment, must not be overwritten).
// Make sure the chunk object is complete (e.g., fetched from DB) before calling this method.