|
@@ -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
|
}
|