diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/repository/DeptRepository.java b/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/repository/DeptRepository.java index a9d67319..61b46480 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/repository/DeptRepository.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/repository/DeptRepository.java @@ -15,6 +15,7 @@ */ package org.nl.modules.system.repository; +import com.sun.org.apache.xpath.internal.operations.Bool; import org.nl.modules.system.domain.Dept; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; @@ -42,6 +43,13 @@ public interface DeptRepository extends JpaRepository, JpaSpecificat */ List findByPidIsNull(); + /** + * 获取激活的部门 + * @param enabled + * @return + */ + List findAllByEnabled(Boolean enabled); + /** * 根据角色ID 查询 * @param roleId 角色ID @@ -66,4 +74,4 @@ public interface DeptRepository extends JpaRepository, JpaSpecificat @Modifying @Query(value = " update sys_dept set sub_count = ?1 where dept_id = ?2 ",nativeQuery = true) void updateSubCntById(Integer count, Long id); -} \ No newline at end of file +} diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/repository/UserRepository.java b/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/repository/UserRepository.java index 76fac5cf..d77a9b2b 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/repository/UserRepository.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/repository/UserRepository.java @@ -16,6 +16,9 @@ package org.nl.modules.system.repository; import org.nl.modules.system.domain.User; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Modifying; diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/rest/UserController.java b/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/rest/UserController.java index aafb773b..19a36c8a 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/rest/UserController.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/rest/UserController.java @@ -86,6 +86,8 @@ public class UserController { if (!ObjectUtils.isEmpty(criteria.getDeptId())) { criteria.getDeptIds().add(criteria.getDeptId()); criteria.getDeptIds().addAll(deptService.getDeptChildren(deptService.findByPid(criteria.getDeptId()))); + } else { + criteria.getDeptIds().addAll(deptService.getDeptEnabled()); } // 数据权限 List dataScopes = dataService.getDeptIds(userService.findByName(SecurityUtils.getCurrentUsername())); diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/service/DeptService.java b/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/service/DeptService.java index 8b3b4b8e..d9c1f8d3 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/service/DeptService.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/service/DeptService.java @@ -48,6 +48,10 @@ public interface DeptService { */ List getDeptChildren(List deptList); + + List getDeptEnabled(); + + /** * 根据ID查询 * diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/service/impl/DeptServiceImpl.java b/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/service/impl/DeptServiceImpl.java index d2356bc4..742f3a22 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/service/impl/DeptServiceImpl.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/service/impl/DeptServiceImpl.java @@ -304,6 +304,16 @@ public class DeptServiceImpl implements DeptService { return list; } + @Override + public List getDeptEnabled() { + List list = new ArrayList<>(); + List enabled = deptRepository.findAllByEnabled(true); + for (Dept dept : enabled) { + list.add(dept.getId()); + } + return list; + } + @Override public Set getChildIdSet(Long pid) { String sql = "select dept_id from (\n" +