From 60a48ba8f8e82f35c3f6262c45eee00b70289c0e Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 31 三月 2021 10:05:55 +0800
Subject: [PATCH] #
---
src/main/java/zy/cloud/wms/manager/controller/NodeController.java | 79 ++++++++++++++++++++++++++++++++++++---
1 files changed, 73 insertions(+), 6 deletions(-)
diff --git a/src/main/java/zy/cloud/wms/manager/controller/NodeController.java b/src/main/java/zy/cloud/wms/manager/controller/NodeController.java
index df36c99..71dfff8 100644
--- a/src/main/java/zy/cloud/wms/manager/controller/NodeController.java
+++ b/src/main/java/zy/cloud/wms/manager/controller/NodeController.java
@@ -12,20 +12,23 @@
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.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.io.IOException;
+import java.util.*;
@RestController
public class NodeController extends BaseController {
@Autowired
private NodeService nodeService;
+ @Autowired
+ private TreeUtils treeUtils;
@RequestMapping(value = "/node/{id}/auth")
@ManagerAuth
@@ -63,6 +66,26 @@
@RequestMapping(value = "/node/add/auth")
@ManagerAuth
public R add(Node node) {
+ if (node.getType() != 1) {
+ Node parentNode = nodeService.selectById(node.getParentId());
+ if (parentNode == null || parentNode.getStatus() == 0) {
+ return R.error(node.getType()==2?"鎵�灞炰粨搴撲笉瀛樺湪":"鎵�灞炲簱鍖轰笉瀛樺湪");
+ }
+ node.setParentName(parentNode.getName());
+ node.setLevel(parentNode.getLevel() + 1);
+ }
+ // path
+ NodeUtils nodeUtils = new NodeUtils();
+ nodeUtils.executePath(node);
+ node.setPath(nodeUtils.path.toString());
+ node.setNamePath(nodeUtils.pathName.toString());
+
+ node.setLevel(node.getType());
+ node.setCreateBy(getUserId());
+ node.setCreateTime(new Date());
+ node.setUpdateBy(getUserId());
+ node.setUpdateTime(new Date());
+ node.setStatus(1);
nodeService.insert(node);
return R.ok();
}
@@ -73,6 +96,22 @@
if (Cools.isEmpty(node) || null==node.getId()){
return R.error();
}
+ if (node.getType() != 1) {
+ Node parentNode = nodeService.selectById(node.getParentId());
+ if (parentNode == null || parentNode.getStatus() == 0) {
+ return R.error(node.getType()==2?"鎵�灞炰粨搴撲笉瀛樺湪":"鎵�灞炲簱鍖轰笉瀛樺湪");
+ }
+ node.setParentName(parentNode.getName());
+ node.setLevel(parentNode.getLevel() + 1);
+ }
+ // path
+ NodeUtils nodeUtils = new NodeUtils();
+ nodeUtils.executePath(node);
+ node.setPath(nodeUtils.path.toString());
+ node.setNamePath(nodeUtils.pathName.toString());
+
+ node.setUpdateBy(getUserId());
+ node.setUpdateTime(new Date());
nodeService.updateById(node);
return R.ok();
}
@@ -105,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).eq("type", 3);
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);
@@ -127,4 +166,32 @@
return R.ok();
}
+ @PostMapping(value = "/parent/node/group")
+ public R getParentNodeGroup(@RequestParam(required = false) String condition,
+ @RequestParam Integer type) {
+ List<Node> nodes = nodeService.selectList(new EntityWrapper<Node>().eq("type", type).eq("status", 1));
+ List<Map<String, Object>> result = new ArrayList<>();
+ for (Node node : nodes) {
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", node.getId());
+ map.put("val", node.getName());
+ result.add(map);
+ }
+ 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);
+ }
+
+
}
--
Gitblit v1.9.1