OrgDao.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package com.uas.console.donate.dao;
  2. import com.uas.console.donate.model.Org;
  3. import org.springframework.data.domain.Page;
  4. import org.springframework.data.domain.Pageable;
  5. import org.springframework.data.jpa.repository.JpaRepository;
  6. import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
  7. import org.springframework.data.jpa.repository.Query;
  8. import org.springframework.data.repository.PagingAndSortingRepository;
  9. import org.springframework.data.repository.query.Param;
  10. import org.springframework.stereotype.Repository;
  11. import java.util.List;
  12. @Repository
  13. public interface OrgDao extends JpaRepository<Org,Long>,JpaSpecificationExecutor<Org>,PagingAndSortingRepository<Org, Long> {
  14. //取出某状态下的所有已正式发布机构
  15. @Query("from Org o where o.status=:status and publish=2")
  16. List<Org> findByStatus(@Param("status")Integer status);
  17. //根据机构类型和状态查询已发布机构
  18. @Query("from Org o where type=:type and status=:status and publish=2 order By createTime desc")
  19. List<Org> findByType(@Param("type") Integer type,@Param("status")Integer status);
  20. //根据机构主要领域和状态查询已发布机构
  21. @Query("from Org o where majorArea=:majorArea and status=:status and publish=2 order By createTime desc")
  22. List<Org> findByMajorArea(@Param("majorArea") Integer majorArea,@Param("status")Integer status);
  23. //根据机构类别,主要领域,状态查询已发布机构
  24. @Query("from Org o where type=:type and majorArea=:majorArea and status=:status and publish=2 order By createTime desc" )
  25. List<Org> findByTypeAndMajorArea(@Param("type") Integer type,@Param("majorArea")Integer majorArea,@Param("status")Integer status);
  26. //根据UUID取出唯一的机构信息
  27. @Query("from Org o where uuid=:uuid")
  28. Org findOne(@Param("uuid") Long uuid);
  29. Page<Org> findAll(Pageable pageable);
  30. //根据搜索框查询机构信息
  31. @Query("from Org o where o.name like %:search%")
  32. List<Org> search(@Param("search") String search);
  33. }