|
@@ -5,7 +5,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
5
|
5
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
6
|
6
|
import com.yunzhi.inte.common.BaseController;
|
7
|
7
|
import com.yunzhi.inte.common.ResponseBean;
|
|
8
|
+
|
8
|
9
|
import java.util.List;
|
|
10
|
+
|
|
11
|
+import com.yunzhi.inte.common.StringUtils;
|
9
|
12
|
import io.swagger.annotations.Api;
|
10
|
13
|
import io.swagger.annotations.ApiOperation;
|
11
|
14
|
import io.swagger.annotations.ApiParam;
|
|
@@ -14,8 +17,9 @@ import org.springframework.web.bind.annotation.*;
|
14
|
17
|
import com.yunzhi.inte.entity.CooperationUnits;
|
15
|
18
|
import com.yunzhi.inte.service.CooperationUnitsService;
|
16
|
19
|
|
17
|
|
- /**
|
|
20
|
+/**
|
18
|
21
|
* 保障机构;(cooperation_units)表控制层
|
|
22
|
+ *
|
19
|
23
|
* @author : http://njyunzhi.com
|
20
|
24
|
* @date : 2022-10-24
|
21
|
25
|
*/
|
|
@@ -23,12 +27,12 @@ import com.yunzhi.inte.service.CooperationUnitsService;
|
23
|
27
|
@RestController
|
24
|
28
|
@RequestMapping("/")
|
25
|
29
|
public class CooperationUnitsController extends BaseController {
|
26
|
|
-
|
|
30
|
+
|
27
|
31
|
@Autowired
|
28
|
32
|
private CooperationUnitsService cooperationUnitsService;
|
29
|
|
-
|
30
|
|
- /**
|
31
|
|
- * 通过ID查询单条数据
|
|
33
|
+
|
|
34
|
+ /**
|
|
35
|
+ * 通过ID查询单条数据
|
32
|
36
|
*
|
33
|
37
|
* @param id 主键
|
34
|
38
|
* @return 实例对象
|
|
@@ -38,28 +42,32 @@ public class CooperationUnitsController extends BaseController {
|
38
|
42
|
public ResponseBean queryById(@ApiParam("对象ID") @PathVariable Integer id) throws Exception {
|
39
|
43
|
return ResponseBean.success(cooperationUnitsService.getById(id));
|
40
|
44
|
}
|
41
|
|
-
|
42
|
|
- /**
|
|
45
|
+
|
|
46
|
+ /**
|
43
|
47
|
* 分页查询
|
44
|
48
|
*
|
45
|
|
- * @param pageNum 当前页码
|
|
49
|
+ * @param pageNum 当前页码
|
46
|
50
|
* @param pageSize 每页条数
|
47
|
51
|
* @return 查询结果
|
48
|
52
|
*/
|
49
|
53
|
@ApiOperation("分页查询")
|
50
|
54
|
@GetMapping("/cooperationUnits")
|
51
|
|
- public ResponseBean list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
52
|
|
- @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
|
53
|
|
-
|
|
55
|
+ public ResponseBean list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
56
|
+ @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
|
57
|
+ @ApiParam("名称") @RequestParam(value = "name", required = false) String name,
|
|
58
|
+ @ApiParam("机构类别") @RequestParam(value = "orgType", required = false) String orgType) throws Exception {
|
|
59
|
+
|
54
|
60
|
IPage<CooperationUnits> pg = new Page<>(pageNum, pageSize);
|
55
|
|
- // QueryWrapper<CooperationUnits> queryWrapper = new QueryWrapper<>();
|
56
|
|
- // queryWrapper.orderByDesc("create_date");
|
57
|
|
- IPage<CooperationUnits> result = cooperationUnitsService.page(pg);
|
58
|
|
-
|
|
61
|
+ QueryWrapper<CooperationUnits> queryWrapper = new QueryWrapper<>();
|
|
62
|
+ queryWrapper.like(!StringUtils.isEmpty(name), "name", name);
|
|
63
|
+ queryWrapper.like(!StringUtils.isEmpty(orgType), "org_type", orgType);
|
|
64
|
+ queryWrapper.orderByDesc("id");
|
|
65
|
+ IPage<CooperationUnits> result = cooperationUnitsService.page(pg, queryWrapper);
|
|
66
|
+
|
59
|
67
|
return ResponseBean.success(result);
|
60
|
68
|
}
|
61
|
|
-
|
62
|
|
- /**
|
|
69
|
+
|
|
70
|
+ /**
|
63
|
71
|
* 新增数据
|
64
|
72
|
*
|
65
|
73
|
* @param cooperationUnits 实例对象
|
|
@@ -71,8 +79,8 @@ public class CooperationUnitsController extends BaseController {
|
71
|
79
|
cooperationUnitsService.save(cooperationUnits);
|
72
|
80
|
return ResponseBean.success(cooperationUnits);
|
73
|
81
|
}
|
74
|
|
-
|
75
|
|
- /**
|
|
82
|
+
|
|
83
|
+ /**
|
76
|
84
|
* 更新数据
|
77
|
85
|
*
|
78
|
86
|
* @param cooperationUnits 实例对象
|
|
@@ -81,12 +89,13 @@ public class CooperationUnitsController extends BaseController {
|
81
|
89
|
@ApiOperation("更新数据")
|
82
|
90
|
@PutMapping("/cooperationUnits/{id}")
|
83
|
91
|
public ResponseBean edit(@ApiParam("对象实体") @RequestBody CooperationUnits cooperationUnits,
|
84
|
|
- @ApiParam("对象ID") @PathVariable Integer id ) throws Exception {
|
|
92
|
+ @ApiParam("对象ID") @PathVariable Integer id) throws Exception {
|
|
93
|
+ cooperationUnits.setId(id);
|
85
|
94
|
cooperationUnitsService.updateById(cooperationUnits);
|
86
|
95
|
return ResponseBean.success(cooperationUnits);
|
87
|
96
|
}
|
88
|
|
-
|
89
|
|
- /**
|
|
97
|
+
|
|
98
|
+ /**
|
90
|
99
|
* 通过主键删除数据
|
91
|
100
|
*
|
92
|
101
|
* @param id 主键
|
|
@@ -94,8 +103,8 @@ public class CooperationUnitsController extends BaseController {
|
94
|
103
|
*/
|
95
|
104
|
@ApiOperation("通过主键删除数据")
|
96
|
105
|
@DeleteMapping("/cooperationUnits/{id}")
|
97
|
|
- public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable Integer id){
|
98
|
|
- cooperationUnitsService.removeLogicById(id);
|
|
106
|
+ public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable Integer id) {
|
|
107
|
+ cooperationUnitsService.removeById(id);
|
99
|
108
|
return ResponseBean.success("success");
|
100
|
109
|
}
|
101
|
110
|
}
|