stjdydayou 4 năm trước cách đây
mục cha
commit
002ecc8d03

+ 36 - 0
src/main/java/com/zhiqiyun/open/mvc/controller/IndexController.java

@@ -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);
     }

+ 2 - 2
src/main/resources/application.properties

@@ -14,8 +14,8 @@ mybatis-plus.config-location=classpath:mybatis/sqlMapConfig.xml
 mybatis-plus.mapper-locations=classpath:mybatis/mappers/*.xml
 mybatis-plus.type-enums-package=com.zhiqiyun.open.core.enmus
 #######################redis###############################
-spring.redis.host=39.99.217.107
-spring.redis.password=hnylredis@
+spring.redis.host=192.168.0.200
+spring.redis.password=123456
 spring.redis.port=6379
 spring.redis.database=1
 ####################### oap config ###############################

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
src/main/resources/public/index.html


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
src/main/resources/public/static/css/chunk-6bc75950.5aa5dc4d.css


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
src/main/resources/public/static/css/chunk-e4c676ba.8d79e416.css


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
src/main/resources/public/static/js/app.b7b88096.js


+ 0 - 0
src/main/resources/public/static/js/chunk-1d9f9eae.087e4c9f.js → src/main/resources/public/static/js/chunk-1d9f9eae.8ee15c2c.js


+ 0 - 0
src/main/resources/public/static/js/chunk-2914c052.102c2629.js → src/main/resources/public/static/js/chunk-2914c052.bcfb975a.js


+ 0 - 0
src/main/resources/public/static/js/chunk-41fc9b08.0c29ed9a.js → src/main/resources/public/static/js/chunk-41fc9b08.a1beebc5.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
src/main/resources/public/static/js/chunk-6bc75950.f2682a2f.js


+ 0 - 0
src/main/resources/public/static/js/chunk-755fa2ec.bdcd3fe6.js → src/main/resources/public/static/js/chunk-755fa2ec.a0a2299c.js


+ 0 - 0
src/main/resources/public/static/js/chunk-78a3203a.795bdd7e.js → src/main/resources/public/static/js/chunk-78a3203a.25a053a1.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
src/main/resources/public/static/js/chunk-e4c676ba.dd197ddd.js


Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác