ResourceLibraryEntityMapper.java 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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> findByUniqueId();
  16. List<ResourceLibraryEntity> findByRegisterAddress(String address);
  17. @Query("{ \"bool\" : { \"must\" : { \"term\" : { \"softwareCopyrightCount\" : 2 } } } }")
  18. List<ResourceLibraryEntity> findByFlag();
  19. // List<ResourceLibraryEntity> findByAnnualRevenue();
  20. @Query("{\"bool\": {\"must\": [{\"nested\": {\"path\": \"annualRevenue\",\"query\": {\"bool\": {\n" +
  21. " \"must\": [{\"match\": {\"annualRevenue.year\": \"2019\"}}],\n" +
  22. " \"filter\":{\"script\":{\"script\":{\"source\":\"73 <= doc['annualRevenue.val'].value && doc['annualRevenue.val'].value < 75\"}}}}}}}]}}")
  23. SearchHits sel(Map<String, Object> param);
  24. @Query("{\"bool\": {\"must\": [{\"nested\": {\"path\": \"annualRevenue\",\"query\": {\"bool\": {\n" +
  25. " \"must\": [{\"match\": {\"annualRevenue.year\": \"?0\"}}],\n" +
  26. " \"filter\":{\"script\":{\"script\":{\"source\":\"73 <= doc['annualRevenue.val'].value && doc['annualRevenue.val'].value < 75\"}}}}}}}]}}")
  27. SearchHits sels(String year);
  28. @Query("{\"bool\": {\"must\": [{\"nested\": {\"path\": \"annualRevenue\",\"query\": {\"bool\": {\n" +
  29. " \"must\": [{\"match\": {\"annualRevenue.year\": \"{param}.year\"}}],\n" +
  30. " \"filter\":{\"script\":{\"script\":{\"source\":\"73 <= doc['annualRevenue.val'].value && doc['annualRevenue.val'].value < 75\"}}}}}}}]}}")
  31. SearchHits selss(@Param("param") Map<String, String> param);
  32. @Query("{\"bool\": {\"must\": [{\"nested\": {\"path\": \"annualRevenue\",\"query\": {\"bool\": {\"must\": \n" +
  33. "[{\"match\": {\"annualRevenue.year\": \"2019\"}},\n" +
  34. "{\"range\":{\"annualRevenue.val\":{\"gte\":23,\"lte\":120}}}\n" +
  35. "]}}}}]}}")
  36. SearchHits selsss(@Param("param") Map<String, String> param);
  37. @Query("{\"match\": {\"name\": {\"query\": \"?0\"}}}")
  38. // Page<Book> findByName(String name, Pageable pageable);
  39. SearchHits findByName(String name, Pageable pageable);
  40. }