用户管理查看禁用部门问题

This commit is contained in:
2022-12-03 11:13:47 +08:00
parent b59abc4263
commit afa20107c7
5 changed files with 28 additions and 1 deletions

View File

@@ -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<Dept, Long>, JpaSpecificat
*/
List<Dept> findByPidIsNull();
/**
* 获取激活的部门
* @param enabled
* @return
*/
List<Dept> findAllByEnabled(Boolean enabled);
/**
* 根据角色ID 查询
* @param roleId 角色ID
@@ -66,4 +74,4 @@ public interface DeptRepository extends JpaRepository<Dept, Long>, JpaSpecificat
@Modifying
@Query(value = " update sys_dept set sub_count = ?1 where dept_id = ?2 ",nativeQuery = true)
void updateSubCntById(Integer count, Long id);
}
}

View File

@@ -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;

View File

@@ -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<Long> dataScopes = dataService.getDeptIds(userService.findByName(SecurityUtils.getCurrentUsername()));

View File

@@ -48,6 +48,10 @@ public interface DeptService {
*/
List<Long> getDeptChildren(List<Dept> deptList);
List<Long> getDeptEnabled();
/**
* 根据ID查询
*

View File

@@ -304,6 +304,16 @@ public class DeptServiceImpl implements DeptService {
return list;
}
@Override
public List<Long> getDeptEnabled() {
List<Long> list = new ArrayList<>();
List<Dept> enabled = deptRepository.findAllByEnabled(true);
for (Dept dept : enabled) {
list.add(dept.getId());
}
return list;
}
@Override
public Set<Long> getChildIdSet(Long pid) {
String sql = "select dept_id from (\n" +