소스 검색

课程管理2级学院过滤

wangliang 11 달 전
부모
커밋
336c96c4a7

+ 2 - 1
distributed-print/src/main/java/com/qmth/distributed/print/api/SysOrgController.java

@@ -51,12 +51,13 @@ public class SysOrgController {
     @RequestMapping(value = "/list", method = RequestMethod.POST)
     public Result list(@ApiParam(value = "指定角色类型") @RequestParam(required = false) RoleTypeEnum specialPrivilege,
                        @ApiParam(value = "是否过滤印刷室") @RequestParam(required = false) boolean withoutPrintingRoom,
+                       @ApiParam(value = "是否过滤二级学院") @RequestParam(required = false) boolean withoutSecondOrg,
                        @ApiParam(value = "课程ID") @RequestParam(required = false) Long courseId,
                        @ApiParam(value = "父机构ID") @RequestParam(required = false) Long orgId,
                        @ApiParam(value = "是否包含课程") @RequestParam(required = false) boolean includeCourse,
                        @ApiParam(value = "是否包含用户") @RequestParam(required = false) boolean includeUser) {
 //        Set<Long> longSet = teachcloudCommonService.listSubOrgIds(orgId);
-        return ResultUtil.ok(sysOrgService.listOrgTree(specialPrivilege, withoutPrintingRoom, courseId, null));
+        return ResultUtil.ok(sysOrgService.listOrgTree(specialPrivilege, withoutPrintingRoom, courseId, null, withoutSecondOrg));
     }
 
     /**

+ 1 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/SysOrgService.java

@@ -25,7 +25,7 @@ public interface SysOrgService extends IService<SysOrg> {
     /**
      * 机构树
      */
-    List<OrgDto> listOrgTree(RoleTypeEnum specialPrivilegeEnum, boolean withoutPrintingRoom, Long courseId, Set<Long> orgId);
+    List<OrgDto> listOrgTree(RoleTypeEnum specialPrivilegeEnum, boolean withoutPrintingRoom, Long courseId, Set<Long> orgId, boolean withoutSecondOrg);
 
     /**
      * 获取所有机构

+ 9 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/SysOrgServiceImpl.java

@@ -69,7 +69,7 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
     private BasicCourseService basicCourseService;
 
     @Override
-    public List<OrgDto> listOrgTree(RoleTypeEnum specialPrivilegeEnum, boolean withoutPrintingRoom, Long courseId, Set<Long> orgIds) {
+    public List<OrgDto> listOrgTree(RoleTypeEnum specialPrivilegeEnum, boolean withoutPrintingRoom, Long courseId, Set<Long> orgIds, boolean withoutSecondOrg) {
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
         List<SysUserResult> finalSysUserResultList = sysUserService.findSysUserResultListNew(schoolId, specialPrivilegeEnum);
         if (!CollectionUtils.isEmpty(finalSysUserResultList)) {
@@ -89,6 +89,14 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
         if (withoutPrintingRoom) {
             orgList = orgList.stream().filter(e -> !OrgTypeEnum.PRINTING_HOUSE.name().equals(e.getType())).collect(Collectors.toList());
         }
+        if (withoutSecondOrg) {
+            List<OrgDto> orgDtoSchoolList = orgList.stream().filter(s -> Objects.nonNull(s.getType()) && Objects.equals(s.getType(), "SCHOOL")).collect(Collectors.toList());
+            if (!CollectionUtils.isEmpty(orgDtoSchoolList) && orgDtoSchoolList.size() == 1) {
+                orgList = orgList.stream().filter(e -> !OrgTypeEnum.PRINTING_HOUSE.name().equals(e.getType()) && Objects.nonNull(e.getParentId()) && e.getParentId().longValue() == orgDtoSchoolList.get(0).getId().longValue()).collect(Collectors.toList());
+            } else {
+                throw ExceptionResultEnum.ERROR.exception("有多条顶级机构");
+            }
+        }
         if (CollectionUtils.isNotEmpty(orgIds)) {
             orgList = orgList.stream().filter(e -> orgIds.contains(e.getId())).collect(Collectors.toList());
         }

+ 1 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/TeachcloudCommonServiceImpl.java

@@ -653,7 +653,7 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
         if (orgId == null) {
             return null;
         }
-        List<OrgDto> orgDtos = sysOrgService.listOrgTree(null, false, null, null);
+        List<OrgDto> orgDtos = sysOrgService.listOrgTree(null, false, null, null, false);
         Set<Long> stringSet = new HashSet<>();
         stringSet.add(orgId);
         stringSet = getOrgIds(stringSet, orgDtos, orgId);

+ 1 - 1
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/SysOrgController.java

@@ -42,7 +42,7 @@ public class SysOrgController {
     @ApiOperation(value = "查询")
     @RequestMapping(value = "/list", method = RequestMethod.POST)
     public Result list() {
-        List<OrgDto> orgDtoList = sysOrgService.listOrgTree(null, false, null, null);
+        List<OrgDto> orgDtoList = sysOrgService.listOrgTree(null, false, null, null, false);
         return ResultUtil.ok(orgDtoList);
     }