jtoms 4 yıl önce
ebeveyn
işleme
685fc495f4

+ 38 - 0
pom.xml

@@ -95,4 +95,42 @@
             <version>${ip2region.version}</version>
         </dependency>
     </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.8.1</version>
+                <configuration>
+                    <source>${maven.compiler.source}</source>
+                    <target>${maven.compiler.target}</target>
+                    <encoding>UTF-8</encoding>
+                </configuration>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.codehaus.plexus</groupId>
+                        <artifactId>plexus-compiler-javac</artifactId>
+                        <version>2.8.5</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <fork>true</fork>
+                    <mainClass>com.zhiqiyun.open.Application</mainClass>
+                    <layout>ZIP</layout>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+        <finalName>${project.artifactId}</finalName>
+    </build>
 </project>

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

@@ -1,17 +1,47 @@
 package com.zhiqiyun.open.mvc.manager.controller;
 
+import com.dliyun.oap.framework.service.RouterService;
+import com.dliyun.oap.framework.service.ServiceMethodHandler;
+import com.zhiqiyun.open.core.service.AppKeyInfoService;
+import com.zhiqiyun.open.mvc.Result;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
 
 @Slf4j
 @Controller
 public class IndexController {
+    @Autowired
+    private RouterService routerService;
+
+    @Autowired
+    private AppKeyInfoService appKeyInfoService;
+
     @GetMapping("/")
     public void index(HttpServletResponse response) throws IOException {
         response.sendRedirect("/index.html");
     }
+
+    @ResponseBody
+    @PostMapping("/dashboard")
+    public Result dashboard() throws IOException {
+        Map<String, ServiceMethodHandler> serviceMethodHandlerMap = this.routerService.getOapContext().getAllServiceMethodHandlers();
+        int serviceMethodHandlerCount = serviceMethodHandlerMap.size();
+
+        long appKeyCount = this.appKeyInfoService.count();
+
+        Map<String, Object> dataMap = new HashMap<>();
+        dataMap.put("serviceMethodHandlerCount", serviceMethodHandlerCount);
+        dataMap.put("appKeyCount", appKeyCount);
+
+        return Result.instance(Result.Code.SUCCESS).setData(dataMap);
+    }
 }