refactor:delete param Long deptId of deptService.getDeptChildren (#525)

pull/530/head
皆非 2020-11-15 19:40:24 +08:00 committed by GitHub
parent 11bf58688a
commit aab6beffc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 9 deletions

View File

@ -79,8 +79,7 @@ public class UserController {
public ResponseEntity<Object> query(UserQueryCriteria criteria, Pageable pageable){
if (!ObjectUtils.isEmpty(criteria.getDeptId())) {
criteria.getDeptIds().add(criteria.getDeptId());
criteria.getDeptIds().addAll(deptService.getDeptChildren(criteria.getDeptId(),
deptService.findByPid(criteria.getDeptId())));
criteria.getDeptIds().addAll(deptService.getDeptChildren(deptService.findByPid(criteria.getDeptId())));
}
// 数据权限
List<Long> dataScopes = dataService.getDeptIds(userService.findByName(SecurityUtils.getCurrentUsername()));

View File

@ -111,11 +111,10 @@ public interface DeptService {
/**
*
* @param deptId
* @param deptList
* @return
*/
List<Long> getDeptChildren(Long deptId, List<Dept> deptList);
List<Long> getDeptChildren(List<Dept> deptList);
/**
*

View File

@ -83,7 +83,7 @@ public class DataServiceImpl implements DataService {
deptIds.add(dept.getId());
List<Dept> deptChildren = deptService.findByPid(dept.getId());
if (deptChildren != null && deptChildren.size() != 0) {
deptIds.addAll(deptService.getDeptChildren(dept.getId(), deptChildren));
deptIds.addAll(deptService.getDeptChildren(deptChildren));
}
}
return deptIds;

View File

@ -172,13 +172,13 @@ public class DeptServiceImpl implements DeptService {
}
@Override
public List<Long> getDeptChildren(Long deptId, List<Dept> deptList) {
public List<Long> getDeptChildren(List<Dept> deptList) {
List<Long> list = new ArrayList<>();
deptList.forEach(dept -> {
if (dept!=null && dept.getEnabled()){
if (dept!=null && dept.getEnabled()) {
List<Dept> depts = deptRepository.findByPid(dept.getId());
if(deptList.size() != 0){
list.addAll(getDeptChildren(dept.getId(), depts));
if (deptList.size() != 0) {
list.addAll(getDeptChildren(depts));
}
list.add(dept.getId());
}