Просмотр исходного кода

企业根据名称和营业执照查询修改

wangmh 8 лет назад
Родитель
Сommit
eda2a44093
1 измененных файлов с 19 добавлено и 2 удалено
  1. 19 2
      sso-server/src/main/java/com/uas/sso/dao/UserspaceDao.java

+ 19 - 2
sso-server/src/main/java/com/uas/sso/dao/UserspaceDao.java

@@ -1,11 +1,17 @@
 package com.uas.sso.dao;
 
 import com.uas.sso.entity.Userspace;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.jpa.repository.QueryHints;
+import org.springframework.data.repository.query.Param;
 
+import javax.persistence.QueryHint;
 import java.util.List;
+import java.util.Set;
 
 /**
  * 企业信息dao,Userspace实体中spaceUU为主键
@@ -21,7 +27,7 @@ public interface UserspaceDao extends JpaRepository<Userspace, Long>, JpaSpecifi
      * @param spaceName 企业名称
      * @return 企业信息
      */
-    Userspace findBySpaceName(String spaceName);
+    Set<Userspace> findBySpaceName(String spaceName);
 
     /**
      * 根据企业营业执照号查找企业信息
@@ -29,7 +35,7 @@ public interface UserspaceDao extends JpaRepository<Userspace, Long>, JpaSpecifi
      * @param businessCode 企业营业执照号
      * @return
      */
-    Userspace findByBusinessCode(String businessCode);
+    Set<Userspace> findByBusinessCode(String businessCode);
 
     /**
      * 找到企业最大的uu号
@@ -61,4 +67,15 @@ public interface UserspaceDao extends JpaRepository<Userspace, Long>, JpaSpecifi
      * @return 企业信息
      */
     List<Userspace> findByBusinessCodeAndValidCode(String businessCode, short validCode);
+
+    /**
+     * 根据关键词搜索相关的企业名
+     * @param keyword 关键词
+     * @param pageable 页面属性
+     * @return
+     */
+    @QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value = "true") })
+    @Query(value = "select t.spaceName from Userspace t where UPPER(t.spaceName) like CONCAT('%',UPPER(:keyword),'%')",
+            countQuery = "select count(t) from Userspace t where UPPER(t.spaceName) like CONCAT('%',UPPER(:keyword),'%')")
+    Page<String> findByPageInfo(@Param("keyword") String keyword, Pageable pageable);
 }