[manager] 系统摘要统计API
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package com.usthe.manager.controller;
|
||||
|
||||
import com.usthe.common.entity.dto.Message;
|
||||
import com.usthe.manager.pojo.dto.AppCount;
|
||||
import com.usthe.manager.pojo.dto.Dashboard;
|
||||
import com.usthe.manager.service.MonitorService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
|
||||
/**
|
||||
* 系统摘要统计API
|
||||
* @author tom
|
||||
* @date 2021/12/7 15:57
|
||||
*/
|
||||
@Api(tags = "系统摘要统计API")
|
||||
@RestController
|
||||
@RequestMapping(path = "/summary", produces = {APPLICATION_JSON_VALUE})
|
||||
public class SummaryController {
|
||||
|
||||
@Autowired
|
||||
private MonitorService monitorService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "查询应用类别监控统计", notes = "查询所有应用类别监控统计信息")
|
||||
public ResponseEntity<Message<Dashboard>> appMonitors() {
|
||||
List<AppCount> appsCount = monitorService.getAllAppMonitorsCount();
|
||||
Message<Dashboard> message = new Message<>(new Dashboard(appsCount));
|
||||
return ResponseEntity.ok(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.usthe.manager.dao;
|
||||
|
||||
import com.usthe.manager.pojo.dto.AppCount;
|
||||
import com.usthe.manager.pojo.entity.Monitor;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -28,4 +30,10 @@ public interface MonitorDao extends JpaRepository<Monitor, Long>, JpaSpecificati
|
||||
*/
|
||||
List<Monitor> findMonitorsByIdIn(Set<Long> monitorIds);
|
||||
|
||||
/**
|
||||
* 查询监控类别及其对应的监控数量
|
||||
* @return 监控类别与监控数量映射
|
||||
*/
|
||||
@Query("select new com.usthe.manager.pojo.dto.AppCount(mo.app, COUNT(mo.id)) from Monitor mo group by mo.app")
|
||||
List<AppCount> findAppsCount();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.usthe.manager.pojo.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author tom
|
||||
* @date 2021/12/7 16:32
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class AppCount {
|
||||
/**监控类型**/
|
||||
private String app;
|
||||
/**监控数量**/
|
||||
private Long size;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.usthe.manager.pojo.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 大屏仪表盘统计信息
|
||||
* @author tom
|
||||
* @date 2021/12/7 16:01
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "大屏仪表盘统计信息")
|
||||
public class Dashboard {
|
||||
|
||||
List<AppCount> apps;
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.usthe.manager.service;
|
||||
|
||||
import com.usthe.manager.pojo.dto.AppCount;
|
||||
import com.usthe.manager.pojo.dto.MonitorDto;
|
||||
import com.usthe.manager.pojo.entity.Monitor;
|
||||
import com.usthe.manager.pojo.entity.Param;
|
||||
@@ -93,4 +94,10 @@ public interface MonitorService {
|
||||
* @param ids 监控IDs
|
||||
*/
|
||||
void enableManageMonitors(HashSet<Long> ids);
|
||||
|
||||
/**
|
||||
* 查询监控类别及其对应的监控数量
|
||||
* @return 监控类别与监控数量映射
|
||||
*/
|
||||
List<AppCount> getAllAppMonitorsCount();
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.usthe.common.util.IpDomainUtil;
|
||||
import com.usthe.common.util.SnowFlakeIdGenerator;
|
||||
import com.usthe.manager.dao.MonitorDao;
|
||||
import com.usthe.manager.dao.ParamDao;
|
||||
import com.usthe.manager.pojo.dto.AppCount;
|
||||
import com.usthe.manager.pojo.dto.MonitorDto;
|
||||
import com.usthe.manager.pojo.entity.Monitor;
|
||||
import com.usthe.manager.pojo.entity.Param;
|
||||
@@ -338,4 +339,10 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppCount> getAllAppMonitorsCount() {
|
||||
return monitorDao.findAppsCount();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user