Parcourir la source

设备类型-父级主菜单

hanqingsong il y a 2 ans
Parent
commit
7201d47088

+ 18 - 6
src/main/java/com/unissoft/basic/controller/BasicDeviceClassifyController.java

@@ -12,13 +12,10 @@ import com.unissoft.common.ResultView;
12 12
 import io.swagger.annotations.Api;
13 13
 import io.swagger.annotations.ApiOperation;
14 14
 import org.springframework.util.StringUtils;
15
-import org.springframework.web.bind.annotation.PostMapping;
16
-import org.springframework.web.bind.annotation.RequestBody;
17
-import org.springframework.web.bind.annotation.RequestMapping;
18
-
19
-import org.springframework.web.bind.annotation.RestController;
15
+import org.springframework.web.bind.annotation.*;
20 16
 
21 17
 import javax.annotation.Resource;
18
+import java.util.List;
22 19
 import java.util.UUID;
23 20
 
24 21
 /**
@@ -49,12 +46,28 @@ public class BasicDeviceClassifyController {
49 46
             return ResultView.error();
50 47
         }
51 48
     }
49
+
50
+    @GetMapping("/getParentList")
51
+    @ApiOperation(value = "父级菜单列表", notes = "所有一级父级list")
52
+    public ResultView getParentList(String classifyName) {
53
+        try {
54
+            List<BasicDeviceClassify> list = basicDeviceClassifyService.getParentList(classifyName);
55
+            return ResultView.success(list);
56
+        } catch (Exception e) {
57
+            e.printStackTrace();
58
+            return ResultView.error();
59
+        }
60
+    }
61
+
52 62
     @PostMapping("/save")
53 63
     @ApiOperation(value = "保存/保存子分类", notes = "更新或保存")
54 64
     public ResultView save(@RequestBody BasicDeviceClassify basicDeviceClassify) {
55 65
         if (StringUtils.isEmpty(basicDeviceClassify.getId())) {
56 66
             basicDeviceClassify.setId(UUID.randomUUID().toString());
57 67
             basicDeviceClassify.setCreateTime(DateUtils.getDate());
68
+            if (StringUtils.isEmpty(basicDeviceClassify.getParentId())) {
69
+                basicDeviceClassify.setParentId("0");
70
+            }
58 71
         }
59 72
         boolean save = basicDeviceClassifyService.saveOrUpdate(basicDeviceClassify);
60 73
         if (save)
@@ -64,5 +77,4 @@ public class BasicDeviceClassifyController {
64 77
     }
65 78
 
66 79
 
67
-
68 80
 }

+ 3 - 0
src/main/java/com/unissoft/basic/service/BasicDeviceClassifyService.java

@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
6 6
 import com.unissoft.basic.model.BasicEnum;
7 7
 import com.unissoft.common.PageParam;
8 8
 
9
+import java.util.List;
10
+
9 11
 /**
10 12
  * <p>
11 13
  * 设备配置-设备分类 服务类
@@ -18,4 +20,5 @@ public interface BasicDeviceClassifyService extends IService<BasicDeviceClassify
18 20
 
19 21
     IPage<BasicDeviceClassify> getPageList(PageParam pageParam);
20 22
 
23
+    List<BasicDeviceClassify> getParentList(String classifyName);
21 24
 }

+ 10 - 0
src/main/java/com/unissoft/basic/service/impl/BasicDeviceClassifyServiceImpl.java

@@ -78,6 +78,16 @@ public class BasicDeviceClassifyServiceImpl extends ServiceImpl<BasicDeviceClass
78 78
         return enumPage;
79 79
     }
80 80
 
81
+    @Override
82
+    public List<BasicDeviceClassify> getParentList(String classifyName) {
83
+        QueryWrapper<BasicDeviceClassify> ew = new QueryWrapper<>();
84
+        ew.orderByDesc("create_time");
85
+        ew.eq("parent_id", "0");
86
+        if (!StringUtils.isEmpty(classifyName))
87
+            ew.like("classify_name", classifyName);
88
+        return basicDeviceClassifyMapper.selectList(ew);
89
+    }
90
+
81 91
     /**
82 92
      * 查询所有设备分类数据
83 93
      *