package ai.decompile.analysis.model.repository;

import ai.decompile.analysis.model.entity.StaticImport;
import java.util.List;
import java.util.UUID;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface StaticImportRepository extends JpaRepository<StaticImport, UUID> {
  List<StaticImport> findByAnalysisIdOrderByDllAscNameAsc(UUID analysisId);

  @Query(
      "SELECT i FROM StaticImport i WHERE i.analysis.id = :analysisId AND (LOWER(i.name) LIKE LOWER(CONCAT('%', :term, '%')) OR LOWER(i.dll) LIKE LOWER(CONCAT('%', :term, '%')))")
  List<StaticImport> searchByNameOrDll(
      @Param("analysisId") UUID analysisId, @Param("term") String term);
}
