|
|
@@ -10,10 +10,12 @@ import cn.reghao.devops.manager.app.model.dto.CopyAppDto;
|
|
|
import cn.reghao.devops.common.build.model.LocalBuildDir;
|
|
|
import cn.reghao.devops.manager.app.model.po.config.AppDeployConfig;
|
|
|
import cn.reghao.devops.manager.app.model.vo.BuildConfig;
|
|
|
+import cn.reghao.devops.manager.app.service.bd.BuildLogService;
|
|
|
import cn.reghao.devops.manager.app.service.bd.BuildStat;
|
|
|
import cn.reghao.devops.manager.app.service.config.AppConfigService;
|
|
|
import cn.reghao.devops.manager.app.service.bd.DeployStat;
|
|
|
import cn.reghao.devops.common.build.chain.BuildTools;
|
|
|
+import cn.reghao.devops.manager.app.service.config.AppDeployConfigService;
|
|
|
import cn.reghao.devops.manager.monitor.service.AppMonitorService;
|
|
|
import cn.reghao.jutil.jdk.result.Result;
|
|
|
import cn.reghao.jutil.jdk.result.ResultStatus;
|
|
|
@@ -33,21 +35,21 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class AppConfigServiceImpl implements AppConfigService {
|
|
|
private final AppConfigRepository appConfigRepository;
|
|
|
- private final AppDeployConfigRepository deployConfigRepository;
|
|
|
private final BuildConfigChecker buildConfigChecker;
|
|
|
private final BuildStat buildStat;
|
|
|
- private final DeployStat deployStat;
|
|
|
private final AppMonitorService appMonitorService;
|
|
|
+ private final AppDeployConfigService deployConfigService;
|
|
|
+ private final BuildLogService buildLogService;
|
|
|
|
|
|
- public AppConfigServiceImpl(AppConfigRepository appConfigRepository, AppDeployConfigRepository deployConfigRepository,
|
|
|
- BuildConfigChecker buildConfigChecker, BuildStat buildStat, DeployStat deployStat,
|
|
|
- AppMonitorService appMonitorService) {
|
|
|
+ public AppConfigServiceImpl(AppConfigRepository appConfigRepository, BuildConfigChecker buildConfigChecker,
|
|
|
+ BuildStat buildStat, AppMonitorService appMonitorService,
|
|
|
+ AppDeployConfigService deployConfigService, BuildLogService buildLogService) {
|
|
|
this.appConfigRepository = appConfigRepository;
|
|
|
- this.deployConfigRepository = deployConfigRepository;
|
|
|
this.buildConfigChecker = buildConfigChecker;
|
|
|
this.buildStat = buildStat;
|
|
|
- this.deployStat = deployStat;
|
|
|
this.appMonitorService = appMonitorService;
|
|
|
+ this.deployConfigService = deployConfigService;
|
|
|
+ this.buildLogService = buildLogService;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -159,34 +161,18 @@ public class AppConfigServiceImpl implements AppConfigService {
|
|
|
|
|
|
@Override
|
|
|
public Result delete(String appId) {
|
|
|
- //return Result.success("暂未实现删除");
|
|
|
-
|
|
|
- if (deployStat.isRunning(appId)) {
|
|
|
- return Result.result(ResultStatus.FAIL, appId + " 正在运行中, 不能删除");
|
|
|
- }
|
|
|
-
|
|
|
- AppConfig appConfig = appConfigRepository.findByAppId(appId);
|
|
|
- if (appConfig == null) {
|
|
|
+ AppConfig app = appConfigRepository.findByAppId(appId);
|
|
|
+ if (app == null) {
|
|
|
return Result.result(ResultStatus.FAIL, appId + " 不存在");
|
|
|
}
|
|
|
|
|
|
- List<AppDeployConfig> deployConfigs = deployConfigRepository.findByAppConfig(appConfig);
|
|
|
- if (!deployConfigs.isEmpty()) {
|
|
|
- deployConfigs.forEach(appDeployConfig -> {
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
- return Result.result(ResultStatus.FAIL, "应用还有部署配置, 不能删除");
|
|
|
- }
|
|
|
-
|
|
|
- delete(appConfig);
|
|
|
- return Result.result(ResultStatus.SUCCESS);
|
|
|
- }
|
|
|
-
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void delete(AppConfig app) {
|
|
|
BuildTools.removeApp(app.getAppId());
|
|
|
+ appMonitorService.delete(app);
|
|
|
+ deployConfigService.delete(app);
|
|
|
+ buildLogService.delete(app);
|
|
|
appConfigRepository.delete(app);
|
|
|
+ buildStat.delete(app);
|
|
|
+ return Result.result(ResultStatus.SUCCESS);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -201,4 +187,15 @@ public class AppConfigServiceImpl implements AppConfigService {
|
|
|
return Result.result(ResultStatus.FAIL, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result batchDelete(List<String> appIds) {
|
|
|
+ for (String appId : appIds) {
|
|
|
+ Result result = delete(appId);
|
|
|
+ if (result.getCode() != 0) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result.result(ResultStatus.SUCCESS);
|
|
|
+ }
|
|
|
}
|