Your Name 2 年之前
父節點
當前提交
a4d688db8f

+ 32
- 3
src/main/java/com/njyunzhi/servsummary/controller/TaEcsController.java 查看文件

@@ -4,8 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.njyunzhi.servsummary.common.BaseController;
7
+import com.njyunzhi.servsummary.common.Constants;
7 8
 import com.njyunzhi.servsummary.common.ResponseBean;
8 9
 import java.util.List;
10
+
11
+import com.njyunzhi.servsummary.common.StringUtils;
12
+import com.njyunzhi.servsummary.entity.TaSsl;
9 13
 import io.swagger.annotations.Api;
10 14
 import io.swagger.annotations.ApiOperation;
11 15
 import io.swagger.annotations.ApiParam;
@@ -49,11 +53,16 @@ public class TaEcsController extends BaseController {
49 53
     @ApiOperation("分页查询")
50 54
     @GetMapping("/taEcs")
51 55
     public ResponseBean list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-                            @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
56
+                            @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
57
+                             @ApiParam("名称") @RequestParam(value = "name", required = false) String name,
58
+                             @ApiParam("状态") @RequestParam(value = "status", required = false) Integer status) throws Exception {
53 59
         
54 60
         IPage<TaEcs> pg = new Page<>(pageNum, pageSize);
55
-        // QueryWrapper<TaEcs> queryWrapper = new QueryWrapper<>();
56
-        // queryWrapper.orderByDesc("create_date");
61
+         QueryWrapper<TaEcs> queryWrapper = new QueryWrapper<>();
62
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
63
+        queryWrapper.eq(null != status, "status", status);
64
+        queryWrapper.like(!StringUtils.isEmpty(name), "name", name);
65
+        queryWrapper.orderByAsc("expire_date");
57 66
         IPage<TaEcs> result = taEcsService.page(pg);
58 67
         
59 68
         return ResponseBean.success(result);
@@ -68,6 +77,15 @@ public class TaEcsController extends BaseController {
68 77
     @ApiOperation("新增数据")
69 78
     @PostMapping("/taEcs")
70 79
     public ResponseBean add(@ApiParam("对象实体") @RequestBody TaEcs taEcs) throws Exception {
80
+        if (StringUtils.isEmpty(taEcs.getName())) {
81
+            return ResponseBean.error("名称不能为空");
82
+        }
83
+
84
+        TaEcs exist = taEcsService.getExistBy("name", taEcs.getName(), false, true);
85
+        if (exist != null) {
86
+            return ResponseBean.error("名称已存在");
87
+        }
88
+
71 89
         taEcsService.save(taEcs);
72 90
         return ResponseBean.success(taEcs);
73 91
     }
@@ -82,6 +100,17 @@ public class TaEcsController extends BaseController {
82 100
     @PutMapping("/taEcs/{id}")
83 101
     public ResponseBean edit(@ApiParam("对象实体") @RequestBody TaEcs taEcs,
84 102
                             @ApiParam("对象ID") @PathVariable String id ) throws Exception {
103
+        taEcs.setEcsId(id);
104
+
105
+        if (StringUtils.isEmpty(taEcs.getName())) {
106
+            return ResponseBean.error("名称不能为空");
107
+        }
108
+
109
+        TaEcs exist = taEcsService.getExistBy("name", taEcs.getName(), false, true);
110
+        if (exist != null && !exist.getEcsId().equals(id)) {
111
+            return ResponseBean.error("名称已存在");
112
+        }
113
+
85 114
         taEcsService.updateById(taEcs);
86 115
         return ResponseBean.success(taEcs);
87 116
     }

+ 25
- 4
src/main/java/com/njyunzhi/servsummary/controller/TaPlatformController.java 查看文件

@@ -10,6 +10,7 @@ import com.njyunzhi.servsummary.common.ResponseBean;
10 10
 import java.util.List;
11 11
 
12 12
 import com.njyunzhi.servsummary.common.StringUtils;
13
+import com.njyunzhi.servsummary.entity.TaEcs;
13 14
 import io.swagger.annotations.Api;
14 15
 import io.swagger.annotations.ApiOperation;
15 16
 import io.swagger.annotations.ApiParam;
@@ -57,12 +58,12 @@ public class TaPlatformController extends BaseController {
57 58
                              @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) throws Exception {
58 59
 
59 60
         IPage<TaPlatform> pg = new Page<>(pageNum, pageSize);
60
-//        QueryWrapper<TaPlatform> queryWrapper = new QueryWrapper<>();
61
-//        queryWrapper.gt("status", Constants.STATUS_DELETE);
61
+        QueryWrapper<TaPlatform> queryWrapper = new QueryWrapper<>();
62
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
62 63
 //        queryWrapper.eq(null != status, "status", status);
63 64
 //        queryWrapper.like(!StringUtils.isEmpty(url), "url", url);
64
-//        queryWrapper.orderByAsc("expire_date");
65
-        IPage<TaPlatform> result = taPlatformService.page(pg);
65
+        queryWrapper.orderByDesc("create_date");
66
+        IPage<TaPlatform> result = taPlatformService.page(pg, queryWrapper);
66 67
 
67 68
         return ResponseBean.success(result);
68 69
     }
@@ -76,6 +77,15 @@ public class TaPlatformController extends BaseController {
76 77
     @ApiOperation("新增数据")
77 78
     @PostMapping("/taPlatform")
78 79
     public ResponseBean add(@ApiParam("对象实体") @RequestBody TaPlatform taPlatform) throws Exception {
80
+        if (StringUtils.isEmpty(taPlatform.getName())) {
81
+            return ResponseBean.error("名称不能为空");
82
+        }
83
+
84
+        TaPlatform exist = taPlatformService.getExistBy("name", taPlatform.getName(), false, true);
85
+        if (exist != null) {
86
+            return ResponseBean.error("名称已存在");
87
+        }
88
+
79 89
         taPlatformService.save(taPlatform);
80 90
         return ResponseBean.success(taPlatform);
81 91
     }
@@ -90,6 +100,17 @@ public class TaPlatformController extends BaseController {
90 100
     @PutMapping("/taPlatform/{id}")
91 101
     public ResponseBean edit(@ApiParam("对象实体") @RequestBody TaPlatform taPlatform,
92 102
                              @ApiParam("对象ID") @PathVariable String id) throws Exception {
103
+        taPlatform.setCloudId(id);
104
+
105
+        if (StringUtils.isEmpty(taPlatform.getName())) {
106
+            return ResponseBean.error("名称不能为空");
107
+        }
108
+
109
+        TaPlatform exist = taPlatformService.getExistBy("name", taPlatform.getName(), false, true);
110
+        if (exist != null && !exist.getCloudId().equals(id)) {
111
+            return ResponseBean.error("名称已存在");
112
+        }
113
+
93 114
         taPlatformService.updateById(taPlatform);
94 115
         return ResponseBean.success(taPlatform);
95 116
     }