|
@@ -22,8 +22,14 @@ import java.util.stream.Collectors;
|
|
@Service
|
|
@Service
|
|
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements IDepartmentService {
|
|
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements IDepartmentService {
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 是排除区县级
|
|
|
|
+ * @param flag
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
- public List<DepartmentVo> findAll() {
|
|
|
|
|
|
+ public List<DepartmentVo> findAll(Boolean flag) {
|
|
//查询省
|
|
//查询省
|
|
List<Department> provinceList = list(new QueryWrapper<Department>().eq("parent_id", 1L));
|
|
List<Department> provinceList = list(new QueryWrapper<Department>().eq("parent_id", 1L));
|
|
|
|
|
|
@@ -33,10 +39,13 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|
DepartmentVo vo = new DepartmentVo(province);
|
|
DepartmentVo vo = new DepartmentVo(province);
|
|
List<Department> cityList = list(new QueryWrapper<Department>().eq("parent_id", province.getId()));
|
|
List<Department> cityList = list(new QueryWrapper<Department>().eq("parent_id", province.getId()));
|
|
List<DepartmentVo> childrenList = cityList.stream().map(city -> new DepartmentVo(city)).collect(Collectors.toList());
|
|
List<DepartmentVo> childrenList = cityList.stream().map(city -> new DepartmentVo(city)).collect(Collectors.toList());
|
|
|
|
+
|
|
childrenList.stream().forEach(city -> {
|
|
childrenList.stream().forEach(city -> {
|
|
List<Department> districtList = list(new QueryWrapper<Department>().eq("parent_id", city.getId()));
|
|
List<Department> districtList = list(new QueryWrapper<Department>().eq("parent_id", city.getId()));
|
|
- List<DepartmentVo> childrenList1 = districtList.stream().map(district -> new DepartmentVo(district)).collect(Collectors.toList());
|
|
|
|
- city.setChildren(childrenList1);
|
|
|
|
|
|
+ if(!(flag!=null && flag)){
|
|
|
|
+ List<DepartmentVo> childrenList1 = districtList.stream().map(district -> new DepartmentVo(district)).collect(Collectors.toList());
|
|
|
|
+ city.setChildren(childrenList1);
|
|
|
|
+ }
|
|
});
|
|
});
|
|
vo.setChildren(childrenList);
|
|
vo.setChildren(childrenList);
|
|
result.add(vo);
|
|
result.add(vo);
|