|
|
@@ -10,7 +10,6 @@ import cn.reghao.autodop.dmaster.app.repository.build.CompilerConfigRepository;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.build.PackerConfigRepository;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.build.RepoConfigRepository;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.orchestration.NotifierRepository;
|
|
|
-import cn.reghao.autodop.dmaster.app.vo.BuildConfigVO;
|
|
|
import cn.reghao.autodop.dmaster.auth.entity.Role;
|
|
|
import cn.reghao.autodop.dmaster.auth.repository.RoleRepository;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -41,9 +40,6 @@ public class SharedEntityChecker {
|
|
|
this.roleRepository = roleRepository;
|
|
|
}
|
|
|
|
|
|
- public void checkAndSet(AppOrchestration app) {
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 检查构建共享配置
|
|
|
*
|
|
|
@@ -51,28 +47,33 @@ public class SharedEntityChecker {
|
|
|
* @return
|
|
|
* @date 2020-09-30 下午3:17
|
|
|
*/
|
|
|
- private void checkAndSetBuildConfig(AppOrchestration app) throws Exception {
|
|
|
- /*BuildConfig buildConfig = new BuildConfig();
|
|
|
- String repo = buildVO.getRepo();
|
|
|
- RepoConfig appUpdate = repoConfigRepository.findByIsDeleteFalseAndName(repo);
|
|
|
- if (appUpdate == null) {
|
|
|
- throw new Exception(repo + " 不存在...");
|
|
|
- }
|
|
|
- appBuild.setAppUpdate(appUpdate);
|
|
|
+ public void checkAndSetBuildConfig(AppOrchestration app) throws Exception {
|
|
|
+ BuildConfig buildConfig = app.getBuildConfig();
|
|
|
+ if (buildConfig != null) {
|
|
|
+ RepoConfig repo = buildConfig.getRepoConfig();
|
|
|
+ RepoConfig repoEntity = repoConfigRepository.findByIsDeleteFalseAndName(repo.getName());
|
|
|
+ if (repoEntity != null) {
|
|
|
+ buildConfig.setRepoConfig(repoEntity);
|
|
|
+ } else {
|
|
|
+ throw new Exception("仓库配置 " + repo.getName() + " 不存在...");
|
|
|
+ }
|
|
|
|
|
|
- String compiler = buildVO.getCompiler();
|
|
|
- CompilerConfig appCompile = compilerConfigRepository.findByIsDeleteFalseAndName(compiler);
|
|
|
- if (appCompile == null) {
|
|
|
- throw new Exception(compiler + " 不存在...");
|
|
|
- }
|
|
|
- //appBuild.setAppCompile(appCompile);
|
|
|
+ CompilerConfig compiler = buildConfig.getCompilerConfig();
|
|
|
+ CompilerConfig compilerEntity = compilerConfigRepository.findByIsDeleteFalseAndName(compiler.getName());
|
|
|
+ if (compilerEntity != null) {
|
|
|
+ buildConfig.setCompilerConfig(compilerEntity);
|
|
|
+ } else {
|
|
|
+ throw new Exception("编译器配置 " + compiler.getName() + " 不存在...");
|
|
|
+ }
|
|
|
|
|
|
- String packer = buildVO.getPacker();
|
|
|
- PackerConfig appPack = packerConfigRepository.findByIsDeleteFalseAndName(packer);
|
|
|
- if (appPack == null) {
|
|
|
- throw new Exception(packer + " 不存在...");
|
|
|
+ PackerConfig packer = buildConfig.getPackerConfig();
|
|
|
+ PackerConfig packerEntity = packerConfigRepository.findByIsDeleteFalseAndName(packer.getName());
|
|
|
+ if (packerEntity != null) {
|
|
|
+ buildConfig.setPackerConfig(packerEntity);
|
|
|
+ } else {
|
|
|
+ throw new Exception("打包配置 " + packer.getName() + " 不存在...");
|
|
|
+ }
|
|
|
}
|
|
|
- appBuild.setAppPack(appPack);*/
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -82,16 +83,27 @@ public class SharedEntityChecker {
|
|
|
* @return
|
|
|
* @date 2020-09-30 下午3:18
|
|
|
*/
|
|
|
- private void checkAndSetNotifier(AppOrchestration app, String notifier) throws Exception {
|
|
|
- /*if (notifier != null) {
|
|
|
- NotifierConfig notifierConfig = notifierRepository.findByIsDeleteFalseAndName(notifier);
|
|
|
- if (notifierConfig == null) {
|
|
|
- throw new Exception(notifierConfig + " 不存在...");
|
|
|
+ public void checkAndSetNotifier(AppOrchestration app) throws Exception {
|
|
|
+ NotifierConfig notifierConfig = app.getNotifierConfig();
|
|
|
+ if (notifierConfig != null) {
|
|
|
+ NotifierConfig notifierConfigEntity = notifierRepository.findByIsDeleteFalseAndName(notifierConfig.getName());
|
|
|
+ if (notifierConfigEntity != null) {
|
|
|
+ app.setNotifierConfig(notifierConfigEntity);
|
|
|
+ } else {
|
|
|
+ throw new Exception("通知配置 " + notifierConfig.getName() + " 不存在...");
|
|
|
}
|
|
|
- app.setNotification(notification);
|
|
|
- }*/
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private void checkAndSetRole(Role role) throws Exception {
|
|
|
+ public void checkAndSetRole(AppOrchestration app) throws Exception {
|
|
|
+ Role role = app.getRole();
|
|
|
+ if (role != null) {
|
|
|
+ Role roleEntity = roleRepository.findRoleByName(role.getName());
|
|
|
+ if (roleEntity != null) {
|
|
|
+ app.setRole(roleEntity);
|
|
|
+ } else {
|
|
|
+ throw new Exception("角色 " + role.getName() + " 不存在...");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|