package com.agent.management.repository;

import com.agent.management.model.entity.KbChunk;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface KbChunkRepository extends JpaRepository<KbChunk, Long> {

    List<KbChunk> findByDocumentIdOrderByChunkIndexAsc(Long documentId);

    void deleteByDocumentId(Long documentId);

    long countByDocumentId(Long documentId);

    long countByDocumentIdAndVectorIdIsNotNull(Long documentId);

    List<KbChunk> findByDocumentIdAndChunkLevelOrderByChunkIndexAsc(Long documentId, Integer chunkLevel);

    List<KbChunk> findByChunkIdIn(List<String> chunkIds);
}
