From a82718a80316dcffee60785d6f40af2c066591a7 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <xltys1995>
Date: 星期二, 26 一月 2021 21:59:53 +0800
Subject: [PATCH] #
---
src/main/java/zy/cloud/wms/manager/controller/TagController.java | 55 +++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 43 insertions(+), 12 deletions(-)
diff --git a/src/main/java/zy/cloud/wms/manager/controller/TagController.java b/src/main/java/zy/cloud/wms/manager/controller/TagController.java
index 5a4c37f..6f12853 100644
--- a/src/main/java/zy/cloud/wms/manager/controller/TagController.java
+++ b/src/main/java/zy/cloud/wms/manager/controller/TagController.java
@@ -1,6 +1,5 @@
package zy.cloud.wms.manager.controller;
-import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
@@ -15,11 +14,9 @@
import zy.cloud.wms.common.web.BaseController;
import zy.cloud.wms.manager.entity.Tag;
import zy.cloud.wms.manager.service.TagService;
+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.util.*;
@RestController
public class TagController extends BaseController {
@@ -63,6 +60,27 @@
@RequestMapping(value = "/tag/add/auth")
@ManagerAuth
public R add(Tag tag) {
+ tag.setLevel(1);
+ if (tag.getParentId() != null && tag.getParentId() > 0) {
+ Tag parent = tagService.selectById(tag.getParentId());
+ if (parent != null) {
+ tag.setParentName(parent.getName());
+ tag.setLevel(parent.getLevel() + 1);
+ }
+ } else {
+ tag.setParentId(0L);
+ }
+ // path
+ NodeUtils nodeUtils = new NodeUtils();
+ nodeUtils.executePath(tag);
+ tag.setPath(nodeUtils.path.toString());
+ tag.setPathName(nodeUtils.pathName.toString());
+
+ tag.setCreateBy(getUserId());
+ tag.setCreateTime(new Date());
+ tag.setUpdateBy(getUserId());
+ tag.setUpdateTime(new Date());
+ tag.setStatus(1);
tagService.insert(tag);
return R.ok();
}
@@ -73,19 +91,32 @@
if (Cools.isEmpty(tag) || null==tag.getId()){
return R.error();
}
+ if (tag.getParentId() != null && tag.getParentId() > 0) {
+ if (tag.getParentId().equals(tag.getId())) {
+ return R.error("鏁版嵁閿欒");
+ }
+ Tag parent = tagService.selectById(tag.getParentId());
+ if (parent != null) {
+ tag.setParentName(parent.getName());
+ tag.setLevel(parent.getLevel() + 1);
+ }
+ }
+ // path
+ NodeUtils nodeUtils = new NodeUtils();
+ nodeUtils.executePath(tag);
+ tag.setPath(nodeUtils.path.toString());
+ tag.setPathName(nodeUtils.pathName.toString());
+ tag.setUpdateBy(getUserId());
+ tag.setUpdateTime(new Date());
tagService.updateById(tag);
return R.ok();
}
@RequestMapping(value = "/tag/delete/auth")
@ManagerAuth
- public R delete(@RequestParam String param){
- List<Tag> list = JSONArray.parseArray(param, Tag.class);
- if (Cools.isEmpty(list)){
- return R.error();
- }
- for (Tag entity : list){
- tagService.delete(new EntityWrapper<>(entity));
+ public R delete(@RequestParam(value="ids[]") Long[] ids){
+ for (Long id : ids){
+ tagService.deleteById(id);
}
return R.ok();
}
--
Gitblit v1.9.1