#
luxiaotao1123
2021-03-06 af121f9c655a4f9a6ea87d363b294ddd12a77fb5
src/main/java/zy/cloud/wms/manager/controller/NodeController.java
@@ -12,11 +12,14 @@
import com.core.common.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import zy.cloud.wms.common.utils.ListUtils;
import zy.cloud.wms.common.utils.TreeUtils;
import zy.cloud.wms.common.web.BaseController;
import zy.cloud.wms.manager.entity.Node;
import zy.cloud.wms.manager.service.NodeService;
import zy.cloud.wms.manager.utils.NodeUtils;
import java.io.IOException;
import java.util.*;
@RestController
@@ -24,6 +27,8 @@
    @Autowired
    private NodeService nodeService;
    @Autowired
    private TreeUtils treeUtils;
    @RequestMapping(value = "/node/{id}/auth")
    @ManagerAuth
@@ -139,13 +144,13 @@
    @ManagerAuth
    public R query(String condition) {
        EntityWrapper<Node> wrapper = new EntityWrapper<>();
        wrapper.like("name", condition);
        wrapper.like("name", condition).or().like("uuid", condition);
        Page<Node> page = nodeService.selectPage(new Page<>(0, 10), wrapper);
        List<Map<String, Object>> result = new ArrayList<>();
        for (Node node : page.getRecords()){
            Map<String, Object> map = new HashMap<>();
            map.put("id", node.getId());
            map.put("value", node.getName());
            map.put("value", node.getUuid() + "(" +node.getName()+ ")");
            result.add(map);
        }
        return R.ok(result);
@@ -175,4 +180,18 @@
        return R.ok().add(result);
    }
    @PostMapping(value = "/node/tree/auth")
    @ManagerAuth
    public R tree(@RequestParam(required = false, defaultValue = "") String condition) throws IOException, ClassNotFoundException {
        ArrayList<Map> tree = treeUtils.getNodeTree(String.valueOf(getOriginNode().getId()));
        // 深拷贝
        List<Map> result = ListUtils.deepCopy(tree);
        if (!Cools.isEmpty(condition)) {
            treeUtils.remove(condition, result);
            treeUtils.remove(condition, result);
        }
        return R.ok(result);
    }
}