|
|
@@ -1,8 +1,13 @@
|
|
|
package cn.reghao.devops.manager.account.controller;
|
|
|
|
|
|
+import cn.reghao.devops.common.machine.Network;
|
|
|
+import cn.reghao.devops.common.util.NotAvailable;
|
|
|
+import cn.reghao.devops.common.util.jvm.JVM;
|
|
|
+import cn.reghao.devops.common.util.jvm.po.JvmInfo;
|
|
|
+import cn.reghao.devops.common.version.AppVersion;
|
|
|
import cn.reghao.devops.manager.account.model.po.Menu;
|
|
|
import cn.reghao.devops.manager.account.model.po.User;
|
|
|
-import cn.reghao.devops.manager.account.service.IndexService;
|
|
|
+import cn.reghao.devops.manager.account.service.HomeService;
|
|
|
import cn.reghao.devops.manager.account.service.UserContext;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -21,10 +26,16 @@ import java.util.Map;
|
|
|
@Api(tags = "登录页和首页")
|
|
|
@Controller
|
|
|
public class AccountAuthController {
|
|
|
- private final IndexService indexService;
|
|
|
-
|
|
|
- public AccountAuthController(IndexService indexService) {
|
|
|
- this.indexService = indexService;
|
|
|
+ private final JVM jvm;
|
|
|
+ private final Network network;
|
|
|
+ private final AppVersion appVersion;
|
|
|
+ private final HomeService homeService;
|
|
|
+
|
|
|
+ public AccountAuthController(HomeService homeService) {
|
|
|
+ this.jvm = new JVM();
|
|
|
+ this.network = new Network();
|
|
|
+ this.appVersion = AppVersion.getVersion();
|
|
|
+ this.homeService = homeService;
|
|
|
}
|
|
|
|
|
|
@GetMapping("/login")
|
|
|
@@ -40,10 +51,38 @@ public class AccountAuthController {
|
|
|
throw new Exception("未登录");
|
|
|
}
|
|
|
|
|
|
- List<Menu> menus = indexService.userMenus(user.getRole());
|
|
|
- Map<Integer, Menu> treeMenu = indexService.treeMenu(menus);
|
|
|
+ List<Menu> menus = homeService.userMenus(user.getRole());
|
|
|
+ Map<Integer, Menu> treeMenu = homeService.treeMenu(menus);
|
|
|
model.addAttribute("user", user);
|
|
|
model.addAttribute("treeMenu", treeMenu);
|
|
|
return "/main";
|
|
|
}
|
|
|
+
|
|
|
+ @GetMapping("/home")
|
|
|
+ public String home(Model model) {
|
|
|
+ String commitId = NotAvailable.na.getDesc();
|
|
|
+ if (appVersion != null) {
|
|
|
+ commitId = appVersion.getCommitId();
|
|
|
+ }
|
|
|
+
|
|
|
+ JvmInfo jvmInfo = jvm.info();
|
|
|
+ //JvmStat jvmStat = jvm.stat();
|
|
|
+ String osInfo = String.format("%s %s", jvmInfo.getOsName(), jvmInfo.getOsVersion());
|
|
|
+ String jvmInfo1 = String.format("%s %s", jvmInfo.getJvmName(), jvmInfo.getJvmVersion());
|
|
|
+ int pid = jvmInfo.getJvmPid();
|
|
|
+ String startAt = jvmInfo.getJvmStartTime();
|
|
|
+ String ipv4 = network.detail().get(0).getIpv4();
|
|
|
+
|
|
|
+ model.addAttribute("managerVersion", commitId);
|
|
|
+ model.addAttribute("hostAddr", ipv4);
|
|
|
+ model.addAttribute("osInfo", osInfo);
|
|
|
+ model.addAttribute("jvmInfo", jvmInfo1);
|
|
|
+ model.addAttribute("pid", pid);
|
|
|
+ model.addAttribute("startAt", startAt);
|
|
|
+ //model.addAttribute("jvmStat", jvmStat);
|
|
|
+
|
|
|
+ String template = "/home/index";
|
|
|
+ template = "/home/index1";
|
|
|
+ return template;
|
|
|
+ }
|
|
|
}
|