|
|
@@ -1,9 +1,7 @@
|
|
|
package cn.iaun.it.controller;
|
|
|
|
|
|
import cn.iaun.it.model.*;
|
|
|
-import cn.iaun.it.model.vo.monitor.controller.ItMonitorAgentKeyReqVo;
|
|
|
-import cn.iaun.it.model.vo.monitor.controller.ItMonitorAgentReqVo;
|
|
|
-import cn.iaun.it.model.vo.monitor.controller.ItMonitorThresholdGetReqVo;
|
|
|
+import cn.iaun.it.model.vo.monitor.controller.*;
|
|
|
import cn.iaun.it.service.ItMonitorService;
|
|
|
import cn.iaun.it.util.MD5Util;
|
|
|
import cn.iaun.it.util.MyPage;
|
|
|
@@ -243,9 +241,6 @@ public class ItMonitorController {
|
|
|
|
|
|
@PostMapping("/item/set")
|
|
|
public Result<?> setItMonitorItem(@Validated @RequestBody ItMonitorItem itMonitorItem) {
|
|
|
- if (itMonitorItem.getItemId() == null) {
|
|
|
- return new Result<>(ResultCode.FAILED_PARAM_INVALID);
|
|
|
- }
|
|
|
return new Result<>(ResultCode.SUCCESS, itMonitorService.setItem(itMonitorItem));
|
|
|
}
|
|
|
|
|
|
@@ -256,8 +251,50 @@ public class ItMonitorController {
|
|
|
|
|
|
@PostMapping("/threshold/set")
|
|
|
public Result<?> setItMonitorThreshold(ItMonitorThreshold itMonitorThreshold) {
|
|
|
- return null;
|
|
|
+ int result = itMonitorService.setThreshold(itMonitorThreshold);
|
|
|
+ return new Result<>(result == 1 ? ResultCode.SUCCESS : ResultCode.FAILED);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/threshold/del")
|
|
|
+ public Result<?> delItMonitorThreshold(@Validated @RequestBody ItMonitorThresholdDelReqVo ids) {
|
|
|
+ int result = itMonitorService.delThresholdByIds(ids.getItemId(), ids.getResourceId(), ids.getAlarmType());
|
|
|
+ return new Result<>(result == 1 ? ResultCode.SUCCESS : ResultCode.FAILED);
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/alarm/get/{i}")
|
|
|
+ public Result<List<ItMonitorAlarm>> getItMonitorAlarm(@PathVariable String i) {
|
|
|
+ Long id = Long.parseLong(i);
|
|
|
+ return new Result<>(ResultCode.SUCCESS, itMonitorService.getAlarmByResourceId(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/alarm/confirm")
|
|
|
+ public Result<?> setItMonitorAlarmConfirm(@RequestAttribute("userId") Long userId, @Validated @RequestBody ItMonitorAlarmConfirmReqVo itMonitorAlarmConfirmReqVo) {
|
|
|
+ boolean success = itMonitorService.confirmAlarm(
|
|
|
+ itMonitorAlarmConfirmReqVo.getAlarmId(), itMonitorAlarmConfirmReqVo.getItemId(), itMonitorAlarmConfirmReqVo.getResourceId(), userId
|
|
|
+ );
|
|
|
+ return new Result<>(success ? ResultCode.SUCCESS : ResultCode.FAILED);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/data/getItem")
|
|
|
+ public Result<MyPage<ItMonitorData>> getItMonitorDataByIds(@RequestBody ItMonitorDataGetReqVo itMonitorDataGetReqVo) {
|
|
|
+ if (itMonitorDataGetReqVo.getPageNo() == null) {
|
|
|
+ itMonitorDataGetReqVo.setPageNo(1);
|
|
|
+ }
|
|
|
+ if (itMonitorDataGetReqVo.getPageSize() == null) {
|
|
|
+ itMonitorDataGetReqVo.setPageSize(20);
|
|
|
+ }
|
|
|
+ MyPage<ItMonitorData> myPage = new MyPage<>(itMonitorService.getDataByIds(
|
|
|
+ itMonitorDataGetReqVo.getPageNo(), itMonitorDataGetReqVo.getPageSize(),
|
|
|
+ itMonitorDataGetReqVo.getResourceId(), itMonitorDataGetReqVo.getItemId(), itMonitorDataGetReqVo.getDays()
|
|
|
+ ));
|
|
|
+
|
|
|
+ return new Result<>(ResultCode.SUCCESS, myPage);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/data/get/{i}")
|
|
|
+ public Result<List<ItMonitorData>> getItMonitorDataByResourceId(@PathVariable String i) {
|
|
|
+ Long id = Long.parseLong(i);
|
|
|
+ return new Result<>(ResultCode.SUCCESS, itMonitorService.getLatestDataByResourceId(id));
|
|
|
+ }
|
|
|
|
|
|
}
|