UserspaceDao.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package com.uas.sso.dao;
  2. import com.uas.sso.entity.Userspace;
  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.jpa.repository.QueryHints;
  9. import org.springframework.data.repository.query.Param;
  10. import javax.persistence.QueryHint;
  11. import java.util.List;
  12. import java.util.Set;
  13. /**
  14. * 企业信息dao,Userspace实体中spaceUU为主键
  15. *
  16. * @author wangmh
  17. * @date 2018/1/5
  18. */
  19. public interface UserspaceDao extends JpaRepository<Userspace, Long>, JpaSpecificationExecutor<Userspace> {
  20. /**
  21. * 根据企业名称查找企业信息
  22. *
  23. * @param spaceName 企业名称
  24. * @return 企业信息
  25. */
  26. Userspace findBySpaceName(String spaceName);
  27. /**
  28. * 根据企业营业执照号查找企业信息
  29. *
  30. * @param businessCode 企业营业执照号
  31. * @return
  32. */
  33. Userspace findByBusinessCode(String businessCode);
  34. /**
  35. * 找到企业最大的uu号
  36. * @return 最大的uu号
  37. */
  38. @Query("select max(us.spaceUU) from Userspace us")
  39. Long findMaxUU();
  40. /**
  41. * 根据域名查找企业
  42. *
  43. * @param domain 域名
  44. * @return
  45. */
  46. Userspace findByDomain(String domain);
  47. /**
  48. * 根据企业名查询认证状态的企业
  49. * @param spaceName 企业名
  50. * @param validCode 认证状态
  51. * @return 企业信息
  52. */
  53. Userspace findBySpaceNameAndValidCode(String spaceName, Short validCode);
  54. /**
  55. * 根据企业营业执照号查询认证状态的企业
  56. * @param businessCode 企业营业执照号
  57. * @param validCode 认证状态
  58. * @return 企业信息
  59. */
  60. Userspace findByBusinessCodeAndValidCode(String businessCode, short validCode);
  61. /**
  62. * 根据关键词搜索相关的企业名
  63. * @param keyword 关键词
  64. * @param pageable 页面属性
  65. * @return
  66. */
  67. @QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value = "true") })
  68. @Query(value = "select t.spaceName from Userspace t where UPPER(t.spaceName) like CONCAT('%',UPPER(:keyword),'%')",
  69. countQuery = "select count(t) from Userspace t where UPPER(t.spaceName) like CONCAT('%',UPPER(:keyword),'%')")
  70. Page<String> findByPageInfo(@Param("keyword") String keyword, Pageable pageable);
  71. }