|
|
@@ -1,7 +1,12 @@
|
|
|
package com.zhiqiyun.open.mvc.controller;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.dliyun.oap.framework.service.RouterService;
|
|
|
import com.dliyun.oap.framework.service.ServiceMethodHandler;
|
|
|
+import com.zhiqiyun.open.annotation.Permission;
|
|
|
+import com.zhiqiyun.open.core.models.app.ApiRequestLog;
|
|
|
+import com.zhiqiyun.open.core.models.app.AppKeyInfo;
|
|
|
+import com.zhiqiyun.open.core.service.ApiRequestLogService;
|
|
|
import com.zhiqiyun.open.core.service.AppKeyInfoService;
|
|
|
import com.zhiqiyun.open.core.service.PlaceBaseInfoService;
|
|
|
import com.zhiqiyun.open.core.service.UploadFileInfoService;
|
|
|
@@ -15,7 +20,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Slf4j
|
|
|
@@ -29,6 +36,9 @@ public class IndexController {
|
|
|
private AppKeyInfoService appKeyInfoService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private ApiRequestLogService apiRequestLogService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private PlaceBaseInfoService placeBaseInfoService;
|
|
|
|
|
|
@Autowired
|
|
|
@@ -40,6 +50,7 @@ public class IndexController {
|
|
|
}
|
|
|
|
|
|
@ResponseBody
|
|
|
+ @Permission(tags = "控制面板", writeLog = false)
|
|
|
@PostMapping("/dashboard")
|
|
|
public Result dashboard() throws IOException {
|
|
|
Map<String, ServiceMethodHandler> serviceMethodHandlerMap = this.routerService.getOapContext().getAllServiceMethodHandlers();
|
|
|
@@ -49,11 +60,36 @@ public class IndexController {
|
|
|
long placeCount = this.placeBaseInfoService.count();
|
|
|
long fileCount = this.uploadFileInfoService.count();
|
|
|
|
|
|
+
|
|
|
+ QueryWrapper<ApiRequestLog> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.select("app_key appKey", "count(id) value");
|
|
|
+ wrapper.groupBy("app_key");
|
|
|
+ wrapper.orderByDesc("value");
|
|
|
+ wrapper.last("limit 8");
|
|
|
+ List<Map<String, Object>> requestLogPieData = this.apiRequestLogService.listMaps(wrapper);
|
|
|
+ for (Map<String, Object> dataMap : requestLogPieData) {
|
|
|
+ AppKeyInfo appKeyInfo = this.appKeyInfoService.findByAppKey(dataMap.get("appKey").toString());
|
|
|
+ if (appKeyInfo == null) {
|
|
|
+ dataMap.put("name", "未知应用");
|
|
|
+ } else {
|
|
|
+ dataMap.put("name", appKeyInfo.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ wrapper= new QueryWrapper<>();
|
|
|
+ wrapper.select("DATE_FORMAT(service_begin_time, '%Y-%m-%d') d", "count(id) value");
|
|
|
+ wrapper.groupBy("d");
|
|
|
+ wrapper.orderByAsc("d");
|
|
|
+ wrapper.last("limit 15");
|
|
|
+ List<Map<String, Object>> requestLogLineData = this.apiRequestLogService.listMaps(wrapper);
|
|
|
+
|
|
|
Map<String, Object> dataMap = new HashMap<>();
|
|
|
dataMap.put("serviceMethodHandlerCount", serviceMethodHandlerCount);
|
|
|
dataMap.put("appKeyCount", appKeyCount);
|
|
|
dataMap.put("placeCount", placeCount);
|
|
|
dataMap.put("fileCount", fileCount);
|
|
|
+ dataMap.put("requestLogPieData", requestLogPieData);
|
|
|
+ dataMap.put("requestLogLineData", requestLogLineData);
|
|
|
|
|
|
return Result.instance(Result.Code.SUCCESS).setData(dataMap);
|
|
|
}
|