Przeglądaj źródła

Merge branch 'master' of http://git.qmth.com.cn/songyue/ExamCloud-service-core.git

Conflicts:
	core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/OrgApi.java
	core-domain/src/main/java/cn/com/qmth/examcloud/service/core/repo/OrgRepo.java
weiwenhai 7 lat temu
rodzic
commit
eeaad9bec3

+ 7 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/OrgApi.java

@@ -246,6 +246,7 @@ public class OrgApi {
         }
 
     }
+
     /**
     @ApiOperation(value = "查询机构不分页带查询", notes = "不分页带查询")
     @GetMapping("/all")
@@ -258,4 +259,10 @@ public class OrgApi {
         return new ResponseEntity(orgService.findAll(orgCriteria), HttpStatus.OK);
     }
     */
+    
+    @ApiOperation(value = "查询所有学校", notes = "查询所有学校")
+    @GetMapping("/getAllParentOrg")
+    public ResponseEntity getAllParentOrg(){
+    	return new ResponseEntity(orgRepo.findAllParentOrg(), HttpStatus.OK);
+    }
 }

+ 36 - 33
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/repo/OrgRepo.java

@@ -1,37 +1,40 @@
-package cn.com.qmth.examcloud.service.core.repo;
-
-import java.util.List;
-
-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.repository.query.Param;
-import org.springframework.data.repository.query.QueryByExampleExecutor;
-
-import cn.com.qmth.examcloud.service.core.entity.Course;
-import cn.com.qmth.examcloud.service.core.entity.Org;
-
-/**
- * Created by songyue on 17/1/13.
- */
-public interface OrgRepo extends JpaRepository<Org, Long>,QueryByExampleExecutor<Org>, JpaSpecificationExecutor<Org> {
-
-    List<Org> findByRootId(long rootId);
-
-    List<Org> findById(long id);
-
-    @Query(nativeQuery = true,value = "select *from ecs_core_org where parent_id=:parentId")
-    List<Org> findBothByParentId(@Param("parentId") long parentId);
-
-    @Query(nativeQuery = true,value = "select *from ecs_core_org where parent_id=:parentId and enable = 1")
-    List<Org> findByParentId(@Param("parentId") long parentId);
-
+package cn.com.qmth.examcloud.service.core.repo;
+
+import java.util.List;
+
+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.repository.query.Param;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import cn.com.qmth.examcloud.service.core.entity.Org;
+
+/**
+ * Created by songyue on 17/1/13.
+ */
+public interface OrgRepo extends JpaRepository<Org,Long>,QueryByExampleExecutor<Org> , JpaSpecificationExecutor<Org>{
+
+    List<Org> findByRootId(long rootId);
+
+    List<Org> findById(long id);
+
+    @Query(nativeQuery = true,value = "select *from ecs_core_org where parent_id=:parentId")
+    List<Org> findBothByParentId(@Param("parentId") long parentId);
+
+    @Query(nativeQuery = true,value = "select *from ecs_core_org where parent_id=:parentId and enable = 1")
+    List<Org> findByParentId(@Param("parentId") long parentId);
+
     @Query(nativeQuery = true,value = "select *from ecs_core_org where (id=:parentId or parent_id=:parentId) and enable = 1 and type = \"SCHOOL\"")
     List<Org> findAllSchoolByParentId(@Param("parentId") long parentId);
     
     @Query(nativeQuery = true,value = "select *from ecs_core_org where (id=:parentId or parent_id=:parentId) and enable = 1 and type in (\"PRINT_QMTH\",\"PRINT_SHOP\")")
-    List<Org> findAllPrintByParentId(@Param("parentId") long parentId);
-
-    @Query(nativeQuery = true,value = "select *from ecs_core_org where parent_id=:parentId and code=:code and enable = 1")
-	Org findFirstByParentIdAndCode(@Param("parentId") Long parentId, @Param("code")String code);
-}
+    List<Org> findAllPrintByParentId(@Param("parentId") long parentId);
+
+    @Query(nativeQuery = true,value = "select *from ecs_core_org where parent_id=:parentId and code=:code and enable = 1")
+	Org findFirstByParentIdAndCode(@Param("parentId") Long parentId, @Param("code")String code);
+    
+    @Query(nativeQuery = true,value = "select * from ecs_core_org t where t.parent_id = 0 and t.enable = 1 order by t.id")
+    List<Org> findAllParentOrg();
+}
+