|
@@ -23,6 +23,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -88,7 +89,7 @@ public class OrgController extends SuperCacheController<OrgService, Long, Org, O
|
|
|
return success(org);
|
|
|
}
|
|
|
|
|
|
- private Org fillOrg(Org org)
|
|
|
+ private void fillOrg(Org org)
|
|
|
{
|
|
|
if (org.getParentId() == null || org.getParentId() <= 0)
|
|
|
{
|
|
@@ -103,12 +104,12 @@ public class OrgController extends SuperCacheController<OrgService, Long, Org, O
|
|
|
org.setTreePath(StringUtils.join(parent.getTreePath(), parent.getId(), DEF_ROOT_PATH));
|
|
|
}
|
|
|
|
|
|
- return org;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public R<Boolean> handlerDelete(List<Long> ids)
|
|
|
{
|
|
|
+ // TODO 删除所属区域
|
|
|
return this.success(baseService.remove(ids));
|
|
|
}
|
|
|
|
|
@@ -125,9 +126,35 @@ public class OrgController extends SuperCacheController<OrgService, Long, Org, O
|
|
|
public R<List<Org>> tree(@RequestParam(value = "name", required = false) String name,
|
|
|
@RequestParam(value = "status", required = false) Boolean status)
|
|
|
{
|
|
|
- List<Org> list = this.baseService.list(Wraps.<Org>lbQ()
|
|
|
- .like(Org::getLabel, name).eq(Org::getStatus, status).orderByAsc(Org::getSortValue));
|
|
|
- return this.success(TreeUtil.buildTree(list));
|
|
|
+ // 查询平面数据
|
|
|
+ List<Org> rows = this.baseService.list(Wraps.<Org>lbQ()
|
|
|
+ .like(Org::getLabel, name)
|
|
|
+ .eq(Org::getStatus, status)
|
|
|
+ .orderByAsc(Org::getSortValue));
|
|
|
+
|
|
|
+ // 部门ID列表
|
|
|
+ List<Long> ids = rows.stream()
|
|
|
+ .map(Org::getId)
|
|
|
+ .collect(Collectors.toCollection(LinkedList::new));
|
|
|
+
|
|
|
+ // 补充所属区域
|
|
|
+ if (ids.size() > 0)
|
|
|
+ {
|
|
|
+ Map<Long, Map<String, Object>> regions = orgRegionMapper.findByOrgIds(StringUtils.join(ids, ","));
|
|
|
+
|
|
|
+ Map<String, Object> r;
|
|
|
+ for (Org o : rows)
|
|
|
+ {
|
|
|
+ r = regions.get(o.getId());
|
|
|
+ if (null != r)
|
|
|
+ {
|
|
|
+ o.setRegionIds((String) r.getOrDefault("RegionIds", ""));
|
|
|
+ o.setRegions((String) r.getOrDefault("Regions", ""));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return this.success(TreeUtil.buildTree(rows));
|
|
|
}
|
|
|
|
|
|
@Override
|