Your Name 2 anni fa
parent
commit
9ac62f370c

+ 30
- 22
src/main/java/com/njyunzhi/servsummary/controller/TaPlatformController.java Vedi File

@@ -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;
9
+
8 10
 import java.util.List;
11
+
12
+import com.njyunzhi.servsummary.common.StringUtils;
9 13
 import io.swagger.annotations.Api;
10 14
 import io.swagger.annotations.ApiOperation;
11 15
 import io.swagger.annotations.ApiParam;
@@ -14,8 +18,9 @@ import org.springframework.web.bind.annotation.*;
14 18
 import com.njyunzhi.servsummary.entity.TaPlatform;
15 19
 import com.njyunzhi.servsummary.service.TaPlatformService;
16 20
 
17
- /**
21
+/**
18 22
  * 云平台;(ta_platform)表控制层
23
+ *
19 24
  * @author : http://njyunzhi.com
20 25
  * @date : 2022-11-22
21 26
  */
@@ -23,12 +28,12 @@ import com.njyunzhi.servsummary.service.TaPlatformService;
23 28
 @RestController
24 29
 @RequestMapping("/")
25 30
 public class TaPlatformController extends BaseController {
26
-    
31
+
27 32
     @Autowired
28 33
     private TaPlatformService taPlatformService;
29
-    
30
-    /** 
31
-     * 通过ID查询单条数据 
34
+
35
+    /**
36
+     * 通过ID查询单条数据
32 37
      *
33 38
      * @param cloudId 主键
34 39
      * @return 实例对象
@@ -38,28 +43,31 @@ public class TaPlatformController extends BaseController {
38 43
     public ResponseBean queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
39 44
         return ResponseBean.success(taPlatformService.getById(id));
40 45
     }
41
-    
42
-    /** 
46
+
47
+    /**
43 48
      * 分页查询
44 49
      *
45
-     * @param pageNum 当前页码
50
+     * @param pageNum  当前页码
46 51
      * @param pageSize 每页条数
47 52
      * @return 查询结果
48 53
      */
49 54
     @ApiOperation("分页查询")
50 55
     @GetMapping("/taPlatform")
51
-    public ResponseBean list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-                            @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
53
-        
56
+    public ResponseBean list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
57
+                             @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) throws Exception {
58
+
54 59
         IPage<TaPlatform> pg = new Page<>(pageNum, pageSize);
55
-        // QueryWrapper<TaPlatform> queryWrapper = new QueryWrapper<>();
56
-        // queryWrapper.orderByDesc("create_date");
60
+//        QueryWrapper<TaPlatform> queryWrapper = new QueryWrapper<>();
61
+//        queryWrapper.gt("status", Constants.STATUS_DELETE);
62
+//        queryWrapper.eq(null != status, "status", status);
63
+//        queryWrapper.like(!StringUtils.isEmpty(url), "url", url);
64
+//        queryWrapper.orderByAsc("expire_date");
57 65
         IPage<TaPlatform> result = taPlatformService.page(pg);
58
-        
66
+
59 67
         return ResponseBean.success(result);
60 68
     }
61
-    
62
-    /** 
69
+
70
+    /**
63 71
      * 新增数据
64 72
      *
65 73
      * @param taPlatform 实例对象
@@ -71,8 +79,8 @@ public class TaPlatformController extends BaseController {
71 79
         taPlatformService.save(taPlatform);
72 80
         return ResponseBean.success(taPlatform);
73 81
     }
74
-    
75
-    /** 
82
+
83
+    /**
76 84
      * 更新数据
77 85
      *
78 86
      * @param taPlatform 实例对象
@@ -81,12 +89,12 @@ public class TaPlatformController extends BaseController {
81 89
     @ApiOperation("更新数据")
82 90
     @PutMapping("/taPlatform/{id}")
83 91
     public ResponseBean edit(@ApiParam("对象实体") @RequestBody TaPlatform taPlatform,
84
-                            @ApiParam("对象ID") @PathVariable String id ) throws Exception {
92
+                             @ApiParam("对象ID") @PathVariable String id) throws Exception {
85 93
         taPlatformService.updateById(taPlatform);
86 94
         return ResponseBean.success(taPlatform);
87 95
     }
88
-    
89
-    /** 
96
+
97
+    /**
90 98
      * 通过主键删除数据
91 99
      *
92 100
      * @param cloudId 主键
@@ -94,7 +102,7 @@ public class TaPlatformController extends BaseController {
94 102
      */
95 103
     @ApiOperation("通过主键删除数据")
96 104
     @DeleteMapping("/taPlatform/{id}")
97
-    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id){
105
+    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id) {
98 106
         taPlatformService.removeLogicById(id);
99 107
         return ResponseBean.success("success");
100 108
     }

+ 33
- 4
src/main/java/com/njyunzhi/servsummary/controller/TaSslController.java Vedi File

@@ -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.TaPlatform;
9 13
 import io.swagger.annotations.Api;
10 14
 import io.swagger.annotations.ApiOperation;
11 15
 import io.swagger.annotations.ApiParam;
@@ -49,12 +53,17 @@ public class TaSslController extends BaseController {
49 53
     @ApiOperation("分页查询")
50 54
     @GetMapping("/taSsl")
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("URL") @RequestParam(value = "url", required = false) String url,
58
+                             @ApiParam("状态") @RequestParam(value = "status", required = false) Integer status) throws Exception {
53 59
         
54 60
         IPage<TaSsl> pg = new Page<>(pageNum, pageSize);
55
-        // QueryWrapper<TaSsl> queryWrapper = new QueryWrapper<>();
56
-        // queryWrapper.orderByDesc("create_date");
57
-        IPage<TaSsl> result = taSslService.page(pg);
61
+        QueryWrapper<TaSsl> queryWrapper = new QueryWrapper<>();
62
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
63
+        queryWrapper.eq(null != status, "status", status);
64
+        queryWrapper.like(!StringUtils.isEmpty(url), "url", url);
65
+        queryWrapper.orderByAsc("expire_date");
66
+        IPage<TaSsl> result = taSslService.page(pg, queryWrapper);
58 67
         
59 68
         return ResponseBean.success(result);
60 69
     }
@@ -68,6 +77,15 @@ public class TaSslController extends BaseController {
68 77
     @ApiOperation("新增数据")
69 78
     @PostMapping("/taSsl")
70 79
     public ResponseBean add(@ApiParam("对象实体") @RequestBody TaSsl taSsl) throws Exception {
80
+        if (StringUtils.isEmpty(taSsl.getUrl())) {
81
+            return ResponseBean.error("域名不能为空");
82
+        }
83
+
84
+        TaSsl exist = taSslService.getExistBy("url", taSsl.getUrl(), false, true);
85
+        if (exist != null) {
86
+            return ResponseBean.error("域名已存在");
87
+        }
88
+
71 89
         taSslService.save(taSsl);
72 90
         return ResponseBean.success(taSsl);
73 91
     }
@@ -82,6 +100,17 @@ public class TaSslController extends BaseController {
82 100
     @PutMapping("/taSsl/{id}")
83 101
     public ResponseBean edit(@ApiParam("对象实体") @RequestBody TaSsl taSsl,
84 102
                             @ApiParam("对象ID") @PathVariable String id ) throws Exception {
103
+        taSsl.setSslId(id);
104
+
105
+        if (StringUtils.isEmpty(taSsl.getUrl())) {
106
+            return ResponseBean.error("域名不能为空");
107
+        }
108
+
109
+        TaSsl exist = taSslService.getExistBy("url", taSsl.getUrl(), false, true);
110
+        if (exist != null && !exist.getSslId().equals(id)) {
111
+            return ResponseBean.error("域名已存在");
112
+        }
113
+
85 114
         taSslService.updateById(taSsl);
86 115
         return ResponseBean.success(taSsl);
87 116
     }