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