|
@@ -1,7 +1,12 @@
|
|
|
package cn.reghao.devops.manager.config.spring;
|
|
package cn.reghao.devops.manager.config.spring;
|
|
|
|
|
|
|
|
import cn.reghao.devops.common.build.model.constant.CompileType;
|
|
import cn.reghao.devops.common.build.model.constant.CompileType;
|
|
|
|
|
+import cn.reghao.devops.manager.account.db.repository.MenuRepository;
|
|
|
|
|
+import cn.reghao.devops.manager.account.model.dto.AccountRole;
|
|
|
|
|
+import cn.reghao.devops.manager.account.model.po.Menu;
|
|
|
import cn.reghao.devops.manager.account.service.AccountService;
|
|
import cn.reghao.devops.manager.account.service.AccountService;
|
|
|
|
|
+import cn.reghao.devops.manager.account.service.FileService;
|
|
|
|
|
+import cn.reghao.devops.manager.account.service.RoleService;
|
|
|
import cn.reghao.devops.manager.app.db.repository.config.build.CompilerConfigRepository;
|
|
import cn.reghao.devops.manager.app.db.repository.config.build.CompilerConfigRepository;
|
|
|
import cn.reghao.devops.manager.app.model.po.config.build.CompilerConfig;
|
|
import cn.reghao.devops.manager.app.model.po.config.build.CompilerConfig;
|
|
|
import cn.reghao.devops.manager.app.service.config.BuildDirService;
|
|
import cn.reghao.devops.manager.app.service.config.BuildDirService;
|
|
@@ -19,6 +24,7 @@ import org.springframework.boot.ApplicationRunner;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
@@ -31,29 +37,27 @@ import java.util.List;
|
|
|
public class AppLifecycle implements ApplicationRunner, DisposableBean {
|
|
public class AppLifecycle implements ApplicationRunner, DisposableBean {
|
|
|
private final BuildDirService buildDirService;
|
|
private final BuildDirService buildDirService;
|
|
|
private final MachineService machineService;
|
|
private final MachineService machineService;
|
|
|
- private final RoleRepository roleRepository;
|
|
|
|
|
private final LogHandler logHandler;
|
|
private final LogHandler logHandler;
|
|
|
private final CompilerConfigRepository compilerConfigRepository;
|
|
private final CompilerConfigRepository compilerConfigRepository;
|
|
|
|
|
+ private final FileService fileService;
|
|
|
|
|
+ private final RoleService roleService;
|
|
|
private final AccountService accountService;
|
|
private final AccountService accountService;
|
|
|
|
|
|
|
|
- public AppLifecycle(BuildDirService buildDirService, MachineService machineService,
|
|
|
|
|
- RoleRepository roleRepository, LogHandler logHandler,
|
|
|
|
|
- CompilerConfigRepository compilerConfigRepository, AccountService accountService) {
|
|
|
|
|
|
|
+ public AppLifecycle(BuildDirService buildDirService, MachineService machineService, LogHandler logHandler,
|
|
|
|
|
+ CompilerConfigRepository compilerConfigRepository, FileService fileService,
|
|
|
|
|
+ RoleService roleService, AccountService accountService) {
|
|
|
this.buildDirService = buildDirService;
|
|
this.buildDirService = buildDirService;
|
|
|
this.machineService = machineService;
|
|
this.machineService = machineService;
|
|
|
- this.roleRepository = roleRepository;
|
|
|
|
|
this.logHandler = logHandler;
|
|
this.logHandler = logHandler;
|
|
|
this.compilerConfigRepository = compilerConfigRepository;
|
|
this.compilerConfigRepository = compilerConfigRepository;
|
|
|
|
|
+ this.fileService = fileService;
|
|
|
|
|
+ this.roleService = roleService;
|
|
|
this.accountService = accountService;
|
|
this.accountService = accountService;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void run(ApplicationArguments args) {
|
|
|
|
|
- accountService.initAccount();
|
|
|
|
|
- initLogConfig();
|
|
|
|
|
- initBuildDir();
|
|
|
|
|
- initRoles();
|
|
|
|
|
- checkCompilerConfig();
|
|
|
|
|
|
|
+ public void run(ApplicationArguments args) throws IOException {
|
|
|
|
|
+ initSys();
|
|
|
log.info("devops-manager started");
|
|
log.info("devops-manager started");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -63,6 +67,15 @@ public class AppLifecycle implements ApplicationRunner, DisposableBean {
|
|
|
log.info("devops-manager shutdown...");
|
|
log.info("devops-manager shutdown...");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void initSys() throws IOException {
|
|
|
|
|
+ fileService.initLocalStore();
|
|
|
|
|
+ roleService.initRole();
|
|
|
|
|
+ accountService.initAccount();
|
|
|
|
|
+ initLogConfig();
|
|
|
|
|
+ initBuildDir();
|
|
|
|
|
+ checkCompilerConfig();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void initLogConfig() {
|
|
private void initLogConfig() {
|
|
|
String app = "devops-manager";
|
|
String app = "devops-manager";
|
|
|
String host = "localhost";
|
|
String host = "localhost";
|
|
@@ -82,6 +95,7 @@ public class AppLifecycle implements ApplicationRunner, DisposableBean {
|
|
|
}*/
|
|
}*/
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Deprecated
|
|
|
private void initBuildDir() {
|
|
private void initBuildDir() {
|
|
|
String userDir = System.getProperty("user.dir");
|
|
String userDir = System.getProperty("user.dir");
|
|
|
String baseDir = String.format("%s/devops_data", userDir);
|
|
String baseDir = String.format("%s/devops_data", userDir);
|
|
@@ -99,23 +113,6 @@ public class AppLifecycle implements ApplicationRunner, DisposableBean {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void initRoles() {
|
|
|
|
|
- List<Role> roleList = roleRepository.findAll();
|
|
|
|
|
- if (roleList.isEmpty()) {
|
|
|
|
|
- roleList = getRoles();
|
|
|
|
|
- roleRepository.saveAll(roleList);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private List<Role> getRoles() {
|
|
|
|
|
- List<Role> list = new ArrayList<>();
|
|
|
|
|
- for (RoleType roleType : RoleType.values()) {
|
|
|
|
|
- list.add(new Role(roleType.name(), roleType.getName(), roleType.getDesc()));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return list;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private void checkCompilerConfig() {
|
|
private void checkCompilerConfig() {
|
|
|
List<CompilerConfig> list = compilerConfigRepository.findAll();
|
|
List<CompilerConfig> list = compilerConfigRepository.findAll();
|
|
|
for (CompilerConfig compilerConfig : list) {
|
|
for (CompilerConfig compilerConfig : list) {
|