|
|
@@ -1,343 +0,0 @@
|
|
|
-package com.nju.edu.paasMonitorServer.controller;
|
|
|
-
|
|
|
-import com.nju.edu.paasMonitorCommon.dto.CallDto;
|
|
|
-import com.nju.edu.paasMonitorCommon.dto.ErrorDto;
|
|
|
-import com.nju.edu.paasMonitorCommon.dto.EventDto;
|
|
|
-import com.nju.edu.paasMonitorCommon.dto.MetricDto;
|
|
|
-import com.nju.edu.paasMonitorServer.alert.entity.vo.AddConfigVO;
|
|
|
-import com.nju.edu.paasMonitorServer.alert.entity.vo.Config;
|
|
|
-import com.nju.edu.paasMonitorServer.alert.entity.vo.alertmail.AlertMail;
|
|
|
-import com.nju.edu.paasMonitorServer.alert.entity.vo.alertreceiver.AddAlertReceiverVO;
|
|
|
-import com.nju.edu.paasMonitorServer.alert.entity.vo.alertreceiver.AlertReceiver;
|
|
|
-import com.nju.edu.paasMonitorServer.alert.entity.vo.alertreceivergroup.AddAlertReceiverGroupVO;
|
|
|
-import com.nju.edu.paasMonitorServer.alert.entity.vo.alertreceivergroup.AlertReceiverGroup;
|
|
|
-import com.nju.edu.paasMonitorServer.alert.service.ConfigService;
|
|
|
-import com.nju.edu.paasMonitorServer.entity.vo.Error;
|
|
|
-import com.nju.edu.paasMonitorServer.entity.vo.*;
|
|
|
-import com.nju.edu.paasMonitorServer.entity.vo.item.SystemLevel;
|
|
|
-import com.nju.edu.paasMonitorServer.entity.vo.item.metric.MetricGraphVO;
|
|
|
-import com.nju.edu.paasMonitorServer.entity.vo.report.LevelReportVO;
|
|
|
-import com.nju.edu.paasMonitorServer.entity.vo.report.MetricReportVO;
|
|
|
-import com.nju.edu.paasMonitorServer.service.EnumService;
|
|
|
-import com.nju.edu.paasMonitorServer.service.MessageService;
|
|
|
-import com.nju.edu.paasMonitorServer.web.response.Response;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-@RestController
|
|
|
-@RequestMapping(value = "/api", produces = "application/json")
|
|
|
-@Slf4j
|
|
|
-public class PaasMonitorController {
|
|
|
- private final MessageService messageService;
|
|
|
- private final EnumService enumService;
|
|
|
- private final ConfigService configService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- public PaasMonitorController(
|
|
|
- MessageService messageService,
|
|
|
- EnumService enumService,
|
|
|
- ConfigService configService
|
|
|
- ) {
|
|
|
- this.messageService = messageService;
|
|
|
- this.enumService = enumService;
|
|
|
- this.configService = configService;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/log/event")
|
|
|
- public Response<String> log(@RequestBody EventDto message) {
|
|
|
- Event event = new Event(message.getSystem(), message.getCategory(),
|
|
|
- message.getName(), message.getCreateTime(), message.getStatus());
|
|
|
- messageService.collectMessage(event);
|
|
|
- Response<String> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/log/error")
|
|
|
- public Response<String> log(@RequestBody ErrorDto message) {
|
|
|
- Error error = new Error(message.getSystem(), message.getCategory(),
|
|
|
- message.getName(), message.getCreateTime(), message.getMessage(),
|
|
|
- message.getExceptionInfo(), message.getStackTrace());
|
|
|
- messageService.collectMessage(error);
|
|
|
- Response<String> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/log/call")
|
|
|
- public Response<String> log(@RequestBody CallDto message) {
|
|
|
- Call call = new Call(message.getSystem(), message.getCategory(),
|
|
|
- message.getName(), message.getCreateTime(), message.getDuration(),
|
|
|
- message.getStatus());
|
|
|
- messageService.collectMessage(call);
|
|
|
- Response<String> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/log/metric")
|
|
|
- public Response<String> log(@RequestBody MetricDto message) {
|
|
|
- Metric metric = new Metric(message.getSystem(), message.getCategory(),
|
|
|
- message.getName(), message.getCreateTime(), message.getCount(), message.getType());
|
|
|
- messageService.collectMessage(metric);
|
|
|
- Response<String> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/report/call")
|
|
|
- public Response<LevelReportVO> getCallReport(
|
|
|
- @RequestParam long startTime,
|
|
|
- @RequestParam long endTime
|
|
|
- ) {
|
|
|
- List<SystemLevel> data = messageService.getCallByTime(startTime, endTime);
|
|
|
- Response<LevelReportVO> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(new LevelReportVO(startTime, endTime, data));
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/report/call/system")
|
|
|
- public Response<LevelReportVO> getCallReportBySystem(
|
|
|
- @RequestParam long startTime,
|
|
|
- @RequestParam long endTime,
|
|
|
- @RequestParam int systemId
|
|
|
- ) {
|
|
|
- List<SystemLevel> data = messageService.getCallByTimeAndSystem(startTime,
|
|
|
- endTime, systemId);
|
|
|
- Response<LevelReportVO> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(new LevelReportVO(startTime, endTime, data));
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/report/error")
|
|
|
- public Response<LevelReportVO> getErrorReport(
|
|
|
- @RequestParam long startTime,
|
|
|
- @RequestParam long endTime
|
|
|
- ) {
|
|
|
- List<SystemLevel> data = messageService.getErrorByTime(startTime, endTime);
|
|
|
- Response<LevelReportVO> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(new LevelReportVO(startTime, endTime, data));
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/report/error/system")
|
|
|
- public Response<LevelReportVO> getErrorReportBySystem(
|
|
|
- @RequestParam long startTime,
|
|
|
- @RequestParam long endTime,
|
|
|
- @RequestParam int systemId
|
|
|
- ) {
|
|
|
- List<SystemLevel> data = messageService.getErrorByTimeAndSystem(startTime,
|
|
|
- endTime, systemId);
|
|
|
- Response<LevelReportVO> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(new LevelReportVO(startTime, endTime, data));
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/report/event")
|
|
|
- public Response<LevelReportVO> getEventReport(
|
|
|
- @RequestParam long startTime,
|
|
|
- @RequestParam long endTime
|
|
|
- ) {
|
|
|
- List<SystemLevel> data = messageService.getEventByTime(startTime, endTime);
|
|
|
- Response<LevelReportVO> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(new LevelReportVO(startTime, endTime, data));
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/report/event/system")
|
|
|
- public Response<LevelReportVO> getEventReportBySystem(
|
|
|
- @RequestParam long startTime,
|
|
|
- @RequestParam long endTime,
|
|
|
- @RequestParam int systemId
|
|
|
- ) {
|
|
|
- List<SystemLevel> data = messageService.getEventByTimeAndSystem(startTime,
|
|
|
- endTime, systemId);
|
|
|
- Response<LevelReportVO> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(new LevelReportVO(startTime, endTime, data));
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/report/metric")
|
|
|
- public Response<MetricReportVO> getMetricReport(
|
|
|
- @RequestParam long startTime,
|
|
|
- @RequestParam long endTime
|
|
|
- ) {
|
|
|
- List<MetricGraphVO> data = messageService.getMetricByTime(startTime, endTime);
|
|
|
- Response<MetricReportVO> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(new MetricReportVO(startTime, endTime, data));
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/report/metric/system")
|
|
|
- public Response<MetricReportVO> getMetricReportBySystem(
|
|
|
- @RequestParam long startTime,
|
|
|
- @RequestParam long endTime,
|
|
|
- @RequestParam int systemId
|
|
|
- ) {
|
|
|
- List<MetricGraphVO> data = messageService.getMetricByTimeAndSystem(startTime,
|
|
|
- endTime, systemId);
|
|
|
- Response<MetricReportVO> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(new MetricReportVO(startTime, endTime, data));
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/config/get")
|
|
|
- public Response<List<Config>> getConfigByType(
|
|
|
- @RequestParam int type
|
|
|
- ) {
|
|
|
- List<Config> configs = configService.getConfigByType(type);
|
|
|
- Response<List<Config>> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(configs);
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/config/add")
|
|
|
- public Response<Config> addConfig(
|
|
|
- @RequestBody AddConfigVO config
|
|
|
- ) {
|
|
|
- Config res = configService.addConfig(config);
|
|
|
- Response<Config> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(res);
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/config/update")
|
|
|
- public Response<Config> updateConfig(
|
|
|
- @RequestBody Config config
|
|
|
- ) {
|
|
|
- Config config1 = configService.updateConfig(config);
|
|
|
- Response<Config> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(config1);
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/config/delete")
|
|
|
- public Response<Long> deleteConfig(
|
|
|
- @RequestParam long id
|
|
|
- ) {
|
|
|
- configService.deleteConfig(id);
|
|
|
- Response<Long> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(id);
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/config/receiver/get")
|
|
|
- public Response<List<AlertReceiver>> getAlertReceiver() {
|
|
|
- List<AlertReceiver> data = configService.getAlertReceiver();
|
|
|
- Response<List<AlertReceiver>> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(data);
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/config/receiver/add")
|
|
|
- public Response<AlertReceiver> addAlertReceiver(
|
|
|
- @RequestBody AddAlertReceiverVO addAlertReceiverVO
|
|
|
- ) {
|
|
|
- AlertReceiver data = configService.addAlertReceiver(addAlertReceiverVO);
|
|
|
- Response<AlertReceiver> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(data);
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/config/receiver/update")
|
|
|
- public Response<AlertReceiver> updateAlertReceiver(
|
|
|
- @RequestBody AlertReceiver alertReceiver
|
|
|
- ) {
|
|
|
- AlertReceiver data = configService.updateAlertReceiver(alertReceiver);
|
|
|
- Response<AlertReceiver> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(data);
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/config/receiver/delete")
|
|
|
- public Response<Long> deleteAlertReceiver(
|
|
|
- @RequestParam long id
|
|
|
- ) {
|
|
|
- long data = configService.deleteAlertReceiver(id);
|
|
|
- Response<Long> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(data);
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/config/alertMail")
|
|
|
- public Response<List<AlertMail>> getAlertMail(
|
|
|
- @RequestParam long startTime,
|
|
|
- @RequestParam long endTime
|
|
|
- ){
|
|
|
- List<AlertMail> data = configService.getAlertMail(startTime, endTime);
|
|
|
- Response<List<AlertMail>> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(data);
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/config/receiverGroup/get")
|
|
|
- public Response<List<AlertReceiverGroup>> getAlertReceiverGroup() {
|
|
|
- List<AlertReceiverGroup> data = configService.getAlertReceiverGroup();
|
|
|
- Response<List<AlertReceiverGroup>> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(data);
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/config/receiverGroup/add")
|
|
|
- public Response<AlertReceiverGroup> addAlertReceiverGroup(
|
|
|
- @RequestBody AddAlertReceiverGroupVO addAlertReceiverGroupVO
|
|
|
- ) {
|
|
|
- AlertReceiverGroup data = configService.addAlertReceiverGroup(addAlertReceiverGroupVO);
|
|
|
- Response<AlertReceiverGroup> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(data);
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/config/receiverGroup/update")
|
|
|
- public Response<AlertReceiverGroup> updateAlertReceiverGroup(
|
|
|
- @RequestBody AlertReceiverGroup alertReceiverGroup
|
|
|
- ) {
|
|
|
- AlertReceiverGroup data = configService.updateAlertReceiverGroup(alertReceiverGroup);
|
|
|
- Response<AlertReceiverGroup> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(data);
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/config/receiverGroup/delete")
|
|
|
- public Response<Long> deleteAlertReceiverGroup(
|
|
|
- @RequestParam long id
|
|
|
- ) {
|
|
|
- long data = configService.deleteAlertReceiverGroup(id);
|
|
|
- Response<Long> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(data);
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("enum")
|
|
|
- public Response<List<EnumVO>> getEnums() {
|
|
|
- List<EnumVO> data = enumService.getEnums();
|
|
|
- Response<List<EnumVO>> response = new Response<>();
|
|
|
- response.ok();
|
|
|
- response.setData(data);
|
|
|
- return response;
|
|
|
- }
|
|
|
-}
|