|
@@ -0,0 +1,96 @@
|
|
1
|
+package com.yunzhi.inte.controller;
|
|
2
|
+
|
|
3
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
4
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
5
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
6
|
+import com.yunzhi.inte.common.ResponseBean;
|
|
7
|
+import com.yunzhi.inte.entity.Banner;
|
|
8
|
+import com.yunzhi.inte.entity.Info;
|
|
9
|
+import com.yunzhi.inte.entity.Monitor;
|
|
10
|
+import com.yunzhi.inte.service.BannerService;
|
|
11
|
+import com.yunzhi.inte.service.MonitorService;
|
|
12
|
+import org.slf4j.Logger;
|
|
13
|
+import org.slf4j.LoggerFactory;
|
|
14
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
15
|
+import org.springframework.web.bind.annotation.*;
|
|
16
|
+
|
|
17
|
+@RestController
|
|
18
|
+@RequestMapping("/")
|
|
19
|
+public class MonitorController {
|
|
20
|
+ private final Logger logger = LoggerFactory.getLogger(InfoController.class);
|
|
21
|
+
|
|
22
|
+ @Autowired
|
|
23
|
+ public MonitorService monitorService;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+ * 分页查询列表
|
|
27
|
+ * @param pageNum
|
|
28
|
+ * @param pageSize
|
|
29
|
+ * @return
|
|
30
|
+ */
|
|
31
|
+ @RequestMapping(value="/monitor",method= RequestMethod.GET)
|
|
32
|
+ public ResponseBean MonitorPage(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
|
33
|
+ @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
|
|
34
|
+
|
|
35
|
+ IPage<Monitor> pg = new Page<>(pageNum, pageSize);
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+ IPage<Monitor> result = monitorService.page(pg);
|
|
40
|
+ return ResponseBean.success(result);
|
|
41
|
+ }
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+ * 增加
|
|
45
|
+ * Monitor 实体对象
|
|
46
|
+ * @return
|
|
47
|
+ */
|
|
48
|
+ @RequestMapping(value="/monitor",method= RequestMethod.POST)
|
|
49
|
+ public ResponseBean MonitorAdd(@RequestBody Monitor monitor) throws Exception{
|
|
50
|
+
|
|
51
|
+ if (monitorService.save(monitor)){
|
|
52
|
+ return ResponseBean.success(monitor);
|
|
53
|
+ }else {
|
|
54
|
+ return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
55
|
+ }
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+ * 根据id删除对象
|
|
60
|
+ * @param id 实体ID
|
|
61
|
+ */
|
|
62
|
+ @RequestMapping(value="/monitor/{id}", method= RequestMethod.DELETE)
|
|
63
|
+ public ResponseBean MonitorDelete(@PathVariable Integer id) throws Exception{
|
|
64
|
+ if(monitorService.removeById(id)){
|
|
65
|
+ return ResponseBean.success("success");
|
|
66
|
+ }else {
|
|
67
|
+ return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
68
|
+ }
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+ * 修改对象
|
|
73
|
+ * @param id 实体ID
|
|
74
|
+ * Monitor 实体对象
|
|
75
|
+ * @return
|
|
76
|
+ */
|
|
77
|
+ @RequestMapping(value="/monitor/{id}",method= RequestMethod.PUT)
|
|
78
|
+ public ResponseBean MonitorUpdate(@PathVariable Integer id,
|
|
79
|
+ @RequestBody Monitor monitor) throws Exception{
|
|
80
|
+ monitor.setId(id);
|
|
81
|
+ if (monitorService.updateById(monitor)){
|
|
82
|
+ return ResponseBean.success(monitorService.getById(id));
|
|
83
|
+ }else {
|
|
84
|
+ return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
85
|
+ }
|
|
86
|
+ }
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+ * 根据id查询对象
|
|
90
|
+ * @param id 实体ID
|
|
91
|
+ */
|
|
92
|
+ @RequestMapping(value="/monitor/{id}",method= RequestMethod.GET)
|
|
93
|
+ public ResponseBean MonitorId(@PathVariable Integer id) throws Exception{
|
|
94
|
+ return ResponseBean.success(monitorService.getById(id));
|
|
95
|
+ }
|
|
96
|
+}
|