ResourceLibraryEntityMapper.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package com.pavis.app.saasbacken.dao;
  2. import com.pavis.app.saasbacken.entity.ResourceLibraryEntity;
  3. import org.springframework.data.elasticsearch.annotations.Query;
  4. import org.springframework.data.elasticsearch.core.SearchHits;
  5. import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
  6. import org.springframework.data.repository.query.Param;
  7. import org.springframework.stereotype.Repository;
  8. import java.awt.print.Pageable;
  9. import java.util.List;
  10. import java.util.Map;
  11. @Repository
  12. // public interface ResourceLibraryEntityMapper extends ElasticsearchRepository<ResourceLibraryEntity, String> {
  13. public interface ResourceLibraryEntityMapper extends ElasticsearchRepository<ResourceLibraryEntity, String> {
  14. List<ResourceLibraryEntity> findByName(String name);
  15. List<ResourceLibraryEntity> findByRegisterAddress(String address);
  16. @Query("{ \"bool\" : { \"must\" : { \"term\" : { \"softwareCopyrightCount\" : 2 } } } }")
  17. List<ResourceLibraryEntity> findByFlag();
  18. // List<ResourceLibraryEntity> findByAnnualRevenue();
  19. @Query("{\"bool\": {\"must\": [{\"nested\": {\"path\": \"annualRevenue\",\"query\": {\"bool\": {\n" +
  20. " \"must\": [{\"match\": {\"annualRevenue.year\": \"2019\"}}],\n" +
  21. " \"filter\":{\"script\":{\"script\":{\"source\":\"73 <= doc['annualRevenue.val'].value && doc['annualRevenue.val'].value < 75\"}}}}}}}]}}")
  22. SearchHits sel(Map<String, Object> param);
  23. @Query("{\"bool\": {\"must\": [{\"nested\": {\"path\": \"annualRevenue\",\"query\": {\"bool\": {\n" +
  24. " \"must\": [{\"match\": {\"annualRevenue.year\": \"?0\"}}],\n" +
  25. " \"filter\":{\"script\":{\"script\":{\"source\":\"73 <= doc['annualRevenue.val'].value && doc['annualRevenue.val'].value < 75\"}}}}}}}]}}")
  26. SearchHits sels(String year);
  27. @Query("{\"bool\": {\"must\": [{\"nested\": {\"path\": \"annualRevenue\",\"query\": {\"bool\": {\n" +
  28. " \"must\": [{\"match\": {\"annualRevenue.year\": \"{param}.year\"}}],\n" +
  29. " \"filter\":{\"script\":{\"script\":{\"source\":\"73 <= doc['annualRevenue.val'].value && doc['annualRevenue.val'].value < 75\"}}}}}}}]}}")
  30. SearchHits selss(@Param("param") Map<String, String> param);
  31. @Query("{\"bool\": {\"must\": [{\"nested\": {\"path\": \"annualRevenue\",\"query\": {\"bool\": {\"must\": \n" +
  32. "[{\"match\": {\"annualRevenue.year\": \"2019\"}},\n" +
  33. "{\"range\":{\"annualRevenue.val\":{\"gte\":23,\"lte\":120}}}\n" +
  34. "]}}}}]}}")
  35. SearchHits selsss(@Param("param") Map<String, String> param);
  36. @Query("{\"match\": {\"name\": {\"query\": \"?0\"}}}")
  37. // Page<Book> findByName(String name, Pageable pageable);
  38. SearchHits findByName(String name, Pageable pageable);
  39. }