Commit f14a617ca9fa1345adf070bfce23c45ed6491389

Authored by 王彬
1 parent fa3e77b8
Exists in master

optimize monitor controller

src/main/java/com/taover/bazhuayun/analysis/web/controller/manage/HeartbeatController.java
@@ -11,12 +11,16 @@ import org.springframework.web.bind.annotation.PostMapping; @@ -11,12 +11,16 @@ import org.springframework.web.bind.annotation.PostMapping;
11 import org.springframework.web.bind.annotation.PutMapping; 11 import org.springframework.web.bind.annotation.PutMapping;
12 import org.springframework.web.bind.annotation.RequestBody; 12 import org.springframework.web.bind.annotation.RequestBody;
13 import org.springframework.web.bind.annotation.RequestMapping; 13 import org.springframework.web.bind.annotation.RequestMapping;
  14 +import org.springframework.web.bind.annotation.RequestParam;
14 import org.springframework.web.bind.annotation.RestController; 15 import org.springframework.web.bind.annotation.RestController;
15 16
  17 +import com.taover.bazhuayun.analysis.web.constants.GlobalConstants;
16 import com.taover.bazhuayun.analysis.web.form.HeartbeatInstanceCreateForm; 18 import com.taover.bazhuayun.analysis.web.form.HeartbeatInstanceCreateForm;
17 import com.taover.bazhuayun.analysis.web.form.HeartbeatInstanceUpdateForm; 19 import com.taover.bazhuayun.analysis.web.form.HeartbeatInstanceUpdateForm;
18 import com.taover.bazhuayun.analysis.web.module.heartbeat.HeartbeatManager; 20 import com.taover.bazhuayun.analysis.web.module.heartbeat.HeartbeatManager;
19 import com.taover.bazhuayun.analysis.web.repository.AnalysisHeartbeatInstanceRepository; 21 import com.taover.bazhuayun.analysis.web.repository.AnalysisHeartbeatInstanceRepository;
  22 +import com.taover.bazhuayun.analysis.web.repository.AnalysisHeartbeatLogRepository;
  23 +import com.taover.bazhuayun.analysis.web.repository.AnalysisHeartbeatReformRepository;
20 import com.taover.util.bean.ResultInfo; 24 import com.taover.util.bean.ResultInfo;
21 import com.taover.util.bean.UtilResultInfo; 25 import com.taover.util.bean.UtilResultInfo;
22 26
@@ -26,36 +30,12 @@ public class HeartbeatController { @@ -26,36 +30,12 @@ public class HeartbeatController {
26 @Resource 30 @Resource
27 private AnalysisHeartbeatInstanceRepository analysisHeartbeatInstanceRepository; 31 private AnalysisHeartbeatInstanceRepository analysisHeartbeatInstanceRepository;
28 @Resource 32 @Resource
  33 + private AnalysisHeartbeatLogRepository analysisHeartbeatLogRepository;
  34 + @Resource
  35 + private AnalysisHeartbeatReformRepository analysisHeartbeatReformRepository;
  36 + @Resource
29 private HeartbeatManager heartbeatManager; 37 private HeartbeatManager heartbeatManager;
30 -  
31 - /**  
32 - * @apiDefine ResultInfo  
33 - * @apiSuccess {string}  
34 - * @apiSuccessExample {json} Success-Response:  
35 - * {  
36 - * code:ok,  
37 - * error:null  
38 - * }  
39 - * @apiError ThrowException 出现异常  
40 - * @apiErrorExample  
41 - * {  
42 - * code:fail,  
43 - * error:null exception  
44 - * }  
45 - */  
46 -  
47 - /**  
48 - * @api {GET} /v1/wxorderauthoper 查询wxorderauthoper列表  
49 - * @apiDescription 查询wxorderauthoper列表数据  
50 - * 返回分页结果  
51 - *  
52 - * @apiGroup wxorderauthoper  
53 - * @apiName wxorderauthoper列表  
54 - * @apiVersion 1.0.0  
55 - * @apiHeader Authorization  
56 - *  
57 - * @apiUse ResultInfo  
58 - */ 38 +
59 @GetMapping 39 @GetMapping
60 public ResultInfo get(HttpServletRequest request){ 40 public ResultInfo get(HttpServletRequest request){
61 String pageStr = request.getParameter("page"); 41 String pageStr = request.getParameter("page");
@@ -66,20 +46,9 @@ public class HeartbeatController { @@ -66,20 +46,9 @@ public class HeartbeatController {
66 if(StringUtils.isEmpty(sizeStr)){ 46 if(StringUtils.isEmpty(sizeStr)){
67 sizeStr = "10"; 47 sizeStr = "10";
68 } 48 }
69 - return UtilResultInfo.getSuccess("", this.analysisHeartbeatInstanceRepository.findPageBySql("1=1", Integer.valueOf(pageStr), Integer.valueOf(sizeStr), null)); 49 + return UtilResultInfo.getSuccess("", this.analysisHeartbeatInstanceRepository.findPageBySql("1=1 order by id desc ", Integer.valueOf(pageStr), Integer.valueOf(sizeStr), null));
70 } 50 }
71 51
72 - /**  
73 - * @api {GET} /v1/wxorderauthoper/{ssid} 查询ssid对应的wxorderauthoper  
74 - * @apiDescription 查询ssid对应wxorderauthoper数据  
75 - *  
76 - * @apiGroup wxorderauthoper  
77 - * @apiName get实体数据  
78 - * @apiVersion 1.0.0  
79 - * @apiHeader Authorization  
80 - *  
81 - * @apiUse ResultInfo  
82 - */  
83 @GetMapping("/{code}") 52 @GetMapping("/{code}")
84 public ResultInfo get(@PathVariable String code){ 53 public ResultInfo get(@PathVariable String code){
85 try { 54 try {
@@ -89,51 +58,40 @@ public class HeartbeatController { @@ -89,51 +58,40 @@ public class HeartbeatController {
89 } 58 }
90 } 59 }
91 60
92 - /**  
93 - * @api {POST} /v1/wxorderauthoper 创建wxorderauthoper  
94 - * @apiDescription 创建wxorderauthoper  
95 - *  
96 - * @apiGroup wxorderauthoper  
97 - * @apiName get实体数据  
98 - * @apiVersion 1.0.0  
99 - * @apiHeader Authorization  
100 - *  
101 - * @apiUse ResultInfo  
102 - */ 61 + @GetMapping("/{code}/log")
  62 + public ResultInfo getLog(@PathVariable String code,
  63 + @RequestParam(defaultValue = ""+GlobalConstants.DEFAULT_QUERY_PAGE) Integer page,
  64 + @RequestParam(defaultValue = ""+GlobalConstants.DEFAULT_QUERY_PAGE_SIZE) Integer size){
  65 + try {
  66 + return UtilResultInfo.getSuccess("", this.analysisHeartbeatLogRepository.findPageBySql("instance_code='"+code+"' order by id desc ", page, size, null));
  67 + } catch (Exception e) {
  68 + return UtilResultInfo.getFailure("not found record");
  69 + }
  70 + }
  71 +
  72 + @GetMapping("/{code}/reform")
  73 + public ResultInfo getReform(@PathVariable String code,
  74 + @RequestParam(defaultValue = ""+GlobalConstants.DEFAULT_QUERY_PAGE) Integer page,
  75 + @RequestParam(defaultValue = ""+GlobalConstants.DEFAULT_QUERY_PAGE_SIZE) Integer size){
  76 + try {
  77 + return UtilResultInfo.getSuccess("", this.analysisHeartbeatReformRepository.findPageBySql("instance_code='"+code+"' order by id desc ", page, size, null));
  78 + } catch (Exception e) {
  79 + return UtilResultInfo.getFailure("not found record");
  80 + }
  81 + }
  82 +
103 @PostMapping 83 @PostMapping
104 public ResultInfo post(@RequestBody HeartbeatInstanceCreateForm form){ 84 public ResultInfo post(@RequestBody HeartbeatInstanceCreateForm form){
105 this.heartbeatManager.createInstance(form); 85 this.heartbeatManager.createInstance(form);
106 return UtilResultInfo.getSuccess("创建成功"); 86 return UtilResultInfo.getSuccess("创建成功");
107 } 87 }
108 88
109 - /**  
110 - * @api {DELETE} /v1/wxorderauthoper/{ssid} 删除ssid对应的wxorderauthoper  
111 - * @apiDescription 删除ssid对应的wxorderauthoper数据  
112 - *  
113 - * @apiGroup wxorderauthoper  
114 - * @apiName 删除实体数据  
115 - * @apiVersion 1.0.0  
116 - * @apiHeader Authorization  
117 - *  
118 - * @apiUse ResultInfo  
119 - */  
120 @DeleteMapping("/{code}") 89 @DeleteMapping("/{code}")
121 public ResultInfo delete(@PathVariable String code){ 90 public ResultInfo delete(@PathVariable String code){
122 this.heartbeatManager.deleteInstance(code); 91 this.heartbeatManager.deleteInstance(code);
123 return UtilResultInfo.getSuccess("删除成功"); 92 return UtilResultInfo.getSuccess("删除成功");
124 } 93 }
125 94
126 - /**  
127 - * @api {PUT} /v1/wxorderauthoper/{ssid} 修改wxorderauthoper数据  
128 - * @apiDescription 修改wxorderauthoper数据  
129 - *  
130 - * @apiGroup wxorderauthoper  
131 - * @apiName 修改实体数据  
132 - * @apiVersion 1.0.0  
133 - * @apiHeader Authorization  
134 - *  
135 - * @apiUse ResultInfo  
136 - */  
137 @PutMapping("/{code}") 95 @PutMapping("/{code}")
138 public ResultInfo put(@PathVariable String code, @RequestBody HeartbeatInstanceUpdateForm form){ 96 public ResultInfo put(@PathVariable String code, @RequestBody HeartbeatInstanceUpdateForm form){
139 this.heartbeatManager.updateInstance(code, form); 97 this.heartbeatManager.updateInstance(code, form);