SysDeptServiceImpl.java
1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.gxb.modules.sys.service.impl;
import com.gxb.modules.sys.dao.SysDeptDao;
import com.gxb.modules.sys.entity.SysDeptEntity;
import com.gxb.modules.sys.service.SysDeptService;
import com.qiniu.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service("sysDeptService")
public class SysDeptServiceImpl implements SysDeptService {
@Autowired
private SysDeptDao sysDeptDao;
@Override
public SysDeptEntity queryObject(Long deptId){
return sysDeptDao.queryObject(deptId);
}
@Override
public List<SysDeptEntity> queryList(Map<String, Object> map){
return sysDeptDao.queryList(map);
}
@Override
public void save(SysDeptEntity sysDept){
sysDeptDao.save(sysDept);
}
@Override
public void update(SysDeptEntity sysDept){
sysDeptDao.update(sysDept);
}
@Override
public void delete(Long deptId){
sysDeptDao.delete(deptId);
}
@Override
public List<Long> queryDetpIdList(Long parentId) {
return sysDeptDao.queryDetpIdList(parentId);
}
@Override
public String getSubDeptIdList(Long deptId){
//部门及子部门ID列表
List<Long> deptIdList = new ArrayList<>();
//获取子部门ID
List<Long> subIdList = queryDetpIdList(deptId);
getDeptTreeList(subIdList, deptIdList);
//添加本部门
deptIdList.add(deptId);
String deptFilter = StringUtils.join(deptIdList, ",");
return deptFilter;
}
/**
* 递归
*/
public void getDeptTreeList(List<Long> subIdList, List<Long> deptIdList){
for(Long deptId : subIdList){
List<Long> list = queryDetpIdList(deptId);
if(list.size() > 0){
getDeptTreeList(list, deptIdList);
}
deptIdList.add(deptId);
}
}
}