Your Name 2 vuotta sitten
vanhempi
commit
f61386f73b

+ 55
- 22
src/main/java/com/njyunzhi/servsummary/controller/TaContcatController.java Näytä tiedosto

@@ -4,8 +4,13 @@ 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;
13
+import com.njyunzhi.servsummary.entity.TaOssBucket;
9 14
 import io.swagger.annotations.Api;
10 15
 import io.swagger.annotations.ApiOperation;
11 16
 import io.swagger.annotations.ApiParam;
@@ -14,8 +19,9 @@ import org.springframework.web.bind.annotation.*;
14 19
 import com.njyunzhi.servsummary.entity.TaContcat;
15 20
 import com.njyunzhi.servsummary.service.TaContcatService;
16 21
 
17
- /**
22
+/**
18 23
  * 联系人;(ta_contcat)表控制层
24
+ *
19 25
  * @author : http://njyunzhi.com
20 26
  * @date : 2022-11-22
21 27
  */
@@ -23,12 +29,12 @@ import com.njyunzhi.servsummary.service.TaContcatService;
23 29
 @RestController
24 30
 @RequestMapping("/")
25 31
 public class TaContcatController extends BaseController {
26
-    
32
+
27 33
     @Autowired
28 34
     private TaContcatService taContcatService;
29
-    
30
-    /** 
31
-     * 通过ID查询单条数据 
35
+
36
+    /**
37
+     * 通过ID查询单条数据
32 38
      *
33 39
      * @param userId 主键
34 40
      * @return 实例对象
@@ -38,28 +44,35 @@ public class TaContcatController extends BaseController {
38 44
     public ResponseBean queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
39 45
         return ResponseBean.success(taContcatService.getById(id));
40 46
     }
41
-    
42
-    /** 
47
+
48
+    /**
43 49
      * 分页查询
44 50
      *
45
-     * @param pageNum 当前页码
51
+     * @param pageNum  当前页码
46 52
      * @param pageSize 每页条数
47 53
      * @return 查询结果
48 54
      */
49 55
     @ApiOperation("分页查询")
50 56
     @GetMapping("/taContcat")
51
-    public ResponseBean list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-                            @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
53
-        
57
+    public ResponseBean list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
58
+                             @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
59
+                             @ApiParam("名称") @RequestParam(value = "name", required = false) String name,
60
+                             @ApiParam("手机号") @RequestParam(value = "phone", required = false) String phone,
61
+                             @ApiParam("状态") @RequestParam(value = "status", required = false) Integer status) throws Exception {
62
+
54 63
         IPage<TaContcat> pg = new Page<>(pageNum, pageSize);
55
-        // QueryWrapper<TaContcat> queryWrapper = new QueryWrapper<>();
56
-        // queryWrapper.orderByDesc("create_date");
64
+        QueryWrapper<TaContcat> queryWrapper = new QueryWrapper<>();
65
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
66
+        queryWrapper.eq(null != status, "status", status);
67
+        queryWrapper.like(!StringUtils.isEmpty(name), "name)", name);
68
+        queryWrapper.like(!StringUtils.isEmpty(name), "phone", phone);
69
+        queryWrapper.orderByDesc("create_date");
57 70
         IPage<TaContcat> result = taContcatService.page(pg);
58
-        
71
+
59 72
         return ResponseBean.success(result);
60 73
     }
61
-    
62
-    /** 
74
+
75
+    /**
63 76
      * 新增数据
64 77
      *
65 78
      * @param taContcat 实例对象
@@ -68,11 +81,20 @@ public class TaContcatController extends BaseController {
68 81
     @ApiOperation("新增数据")
69 82
     @PostMapping("/taContcat")
70 83
     public ResponseBean add(@ApiParam("对象实体") @RequestBody TaContcat taContcat) throws Exception {
84
+        if (StringUtils.isEmpty(taContcat.getName())) {
85
+            return ResponseBean.error("名称不能为空");
86
+        }
87
+
88
+        TaContcat exist = taContcatService.getExistBy("name", taContcat.getName(), false, true);
89
+        if (exist != null) {
90
+            return ResponseBean.error("名称已存在");
91
+        }
92
+
71 93
         taContcatService.save(taContcat);
72 94
         return ResponseBean.success(taContcat);
73 95
     }
74
-    
75
-    /** 
96
+
97
+    /**
76 98
      * 更新数据
77 99
      *
78 100
      * @param taContcat 实例对象
@@ -81,12 +103,23 @@ public class TaContcatController extends BaseController {
81 103
     @ApiOperation("更新数据")
82 104
     @PutMapping("/taContcat/{id}")
83 105
     public ResponseBean edit(@ApiParam("对象实体") @RequestBody TaContcat taContcat,
84
-                            @ApiParam("对象ID") @PathVariable String id ) throws Exception {
106
+                             @ApiParam("对象ID") @PathVariable String id) throws Exception {
107
+        taContcat.setUserId(id);
108
+
109
+        if (StringUtils.isEmpty(taContcat.getName())) {
110
+            return ResponseBean.error("名称不能为空");
111
+        }
112
+
113
+        TaContcat exist = taContcatService.getExistBy("name", taContcat.getName(), false, true);
114
+        if (exist != null && !exist.getUserId().equals(id)) {
115
+            return ResponseBean.error("名称已存在");
116
+        }
117
+
85 118
         taContcatService.updateById(taContcat);
86 119
         return ResponseBean.success(taContcat);
87 120
     }
88
-    
89
-    /** 
121
+
122
+    /**
90 123
      * 通过主键删除数据
91 124
      *
92 125
      * @param userId 主键
@@ -94,7 +127,7 @@ public class TaContcatController extends BaseController {
94 127
      */
95 128
     @ApiOperation("通过主键删除数据")
96 129
     @DeleteMapping("/taContcat/{id}")
97
-    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id){
130
+    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id) {
98 131
         taContcatService.removeLogicById(id);
99 132
         return ResponseBean.success("success");
100 133
     }

+ 1
- 1
src/main/java/com/njyunzhi/servsummary/controller/TaOssBucketController.java Näytä tiedosto

@@ -61,7 +61,7 @@ public class TaOssBucketController extends BaseController {
61 61
         QueryWrapper<TaOssBucket> queryWrapper = new QueryWrapper<>();
62 62
         queryWrapper.gt("status", Constants.STATUS_DELETE);
63 63
         queryWrapper.eq(null != status, "status", status);
64
-        queryWrapper.like(!StringUtils.isEmpty(name), "url", name);
64
+        queryWrapper.like(!StringUtils.isEmpty(name), "name", name);
65 65
         queryWrapper.orderByDesc("create_date");
66 66
         IPage<TaOssBucket> result = taOssBucketService.page(pg, queryWrapper);
67 67
         

+ 30
- 3
src/main/java/com/njyunzhi/servsummary/controller/TaProjectController.java Näytä tiedosto

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