|
@@ -1,13 +1,13 @@
|
|
|
package com.sooka.sponest.data.utils;
|
|
|
|
|
|
+import com.ruoyi.common.core.domain.R;
|
|
|
+import com.ruoyi.common.core.utils.StringUtils;
|
|
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
|
|
import com.ruoyi.system.api.RemoteDeptService;
|
|
|
import com.ruoyi.system.api.domain.SysDept;
|
|
|
-import net.bytebuddy.implementation.bytecode.Throw;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -19,13 +19,16 @@ public class DeptLevelUtil {
|
|
|
@Autowired
|
|
|
private RemoteDeptService remoteDeptService;
|
|
|
|
|
|
- public List<Map<String, Object>> getDeptLevel(List<Map<String,Object>> list) throws IOException {
|
|
|
- List<Map<String,Object>> mapList = new ArrayList<>();
|
|
|
- if (list.isEmpty()||!list.get(0).containsKey("ancestors")){
|
|
|
- throw new IOException("入参为空或入参没有key:'ancestors'");
|
|
|
- }
|
|
|
+ public R getDeptLevel(List<Map<String,Object>> list) {
|
|
|
String deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId().toString();
|
|
|
List<SysDept> sysDeptList = remoteDeptService.selectChildrenCountyOrVillagesDeptListByDeptId(deptId).getData();
|
|
|
+ if (StringUtils.isEmpty(list)&&list==null){
|
|
|
+ return R.ok(sysDeptList);
|
|
|
+ }
|
|
|
+ if (!list.get(0).containsKey("ancestors")||!list.get(0).containsKey("deptId")){
|
|
|
+ return R.fail("入参没有key:'ancestors'或没有key:'deptId'");
|
|
|
+ }
|
|
|
+ List<Map<String,Object>> mapList = new ArrayList<>();
|
|
|
for (SysDept sysDept : sysDeptList){//部门
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
//map中增加key
|
|
@@ -47,6 +50,6 @@ public class DeptLevelUtil {
|
|
|
map.put("deptName",sysDept.getDeptName());
|
|
|
mapList.add(map);
|
|
|
}
|
|
|
- return mapList;
|
|
|
+ return R.ok(mapList);
|
|
|
}
|
|
|
}
|