宋悦 %!s(int64=7) %!d(string=hai) anos
pai
achega
054f1add3c

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

@@ -106,6 +106,18 @@ public class OrgApi {
         return new ResponseEntity(orgRepo.findByParentId(parentId), HttpStatus.OK);
     }
 
+    @ApiOperation(value = "查询下属机构不带分页", notes = "不分页")
+    @GetMapping("/sub/both/{parentId}")
+    public ResponseEntity getBothOrg(@PathVariable Long parentId,HttpServletRequest request) {
+        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+        if(accessUser != null){
+            if(accessUser.getRootOrgId().longValue() != accessUser.getOrgId().longValue()){
+                return new ResponseEntity(orgRepo.findById(parentId), HttpStatus.OK);
+            }
+        }
+        return new ResponseEntity(orgRepo.findBothByParentId(parentId), HttpStatus.OK);
+    }
+
     @ApiOperation(value = "查询下属机构分页带查询", notes = "分页")
     @GetMapping("/sub/{parentId}/{curPage}/{pageSize}")
     public ResponseEntity getAllSubOrg(@ModelAttribute Org orgCriteria,

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

@@ -17,6 +17,9 @@ public interface OrgRepo extends JpaRepository<Org,Long>,QueryByExampleExecutor<
 
     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);