|
|
@@ -8,13 +8,14 @@ import cn.reghao.autodop.dmaster.app.entity.build.update.AppUpdate;
|
|
|
import cn.reghao.autodop.dmaster.app.entity.orchestration.AppOrchestration;
|
|
|
import cn.reghao.autodop.dmaster.app.entity.orchestration.Notification;
|
|
|
import cn.reghao.autodop.dmaster.app.entity.orchestration.ProjOrchestration;
|
|
|
-import cn.reghao.autodop.dmaster.app.repository.orchestration.ProjDAO;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.build.AppCompileRepository;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.build.AppPackRepository;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.build.AppUpdateRepository;
|
|
|
+import cn.reghao.autodop.dmaster.app.repository.orchestration.AppDAO;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.orchestration.AppOrchestrationRepository;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.orchestration.NotificationRepository;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.orchestration.ProjectOrchestrationRepository;
|
|
|
+import cn.reghao.autodop.dmaster.app.vo.AppToBuild;
|
|
|
import cn.reghao.autodop.dmaster.app.vo.PageList;
|
|
|
import cn.reghao.autodop.dmaster.app.vo.ResultVO;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
@@ -37,7 +38,7 @@ public class AppOrchestrateService {
|
|
|
private AppCompileRepository appCompileRepository;
|
|
|
private AppPackRepository appPackRepository;
|
|
|
private NotificationRepository notificationRepository;
|
|
|
- private ProjDAO projDAO;
|
|
|
+ private AppDAO appDAO;
|
|
|
|
|
|
public AppOrchestrateService(ProjectOrchestrationRepository projRepository,
|
|
|
AppOrchestrationRepository appRepository,
|
|
|
@@ -45,14 +46,14 @@ public class AppOrchestrateService {
|
|
|
AppCompileRepository appCompileRepository,
|
|
|
AppPackRepository appPackRepository,
|
|
|
NotificationRepository notificationRepository,
|
|
|
- ProjDAO projDAO) {
|
|
|
+ AppDAO appDAO) {
|
|
|
this.projRepository = projRepository;
|
|
|
this.appRepository = appRepository;
|
|
|
this.appUpdateRepository = appUpdateRepository;
|
|
|
this.appCompileRepository = appCompileRepository;
|
|
|
this.appPackRepository = appPackRepository;
|
|
|
this.notificationRepository = notificationRepository;
|
|
|
- this.projDAO = projDAO;
|
|
|
+ this.appDAO = appDAO;
|
|
|
}
|
|
|
|
|
|
public void add(int type, String json) {
|
|
|
@@ -75,16 +76,23 @@ public class AppOrchestrateService {
|
|
|
}
|
|
|
|
|
|
private void saveApp(AppOrchestration app) {
|
|
|
- String projId = app.getProjId();
|
|
|
- if (projId == null) {
|
|
|
+ ProjOrchestration proj = app.getProj();
|
|
|
+ if (proj != null) {
|
|
|
+ ProjOrchestration projEntity = projRepository.findByProjId(proj.getProjId());
|
|
|
+ if (projEntity != null) {
|
|
|
+ app.setProj(projEntity);
|
|
|
+ } else {
|
|
|
+ projRepository.save(proj);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
AppBuild appBuild = app.getAppBuild();
|
|
|
checkSharedEntity(appBuild);
|
|
|
}
|
|
|
|
|
|
Notification notification = app.getNotification();
|
|
|
- Notification notifyEntity = notificationRepository.findByNotifyName(notification.getNotifyName());
|
|
|
- if (notifyEntity != null) {
|
|
|
- app.setNotification(notifyEntity);
|
|
|
+ Notification notifierEntity = notificationRepository.findByNotifierName(notification.getNotifierName());
|
|
|
+ if (notifierEntity != null) {
|
|
|
+ app.setNotification(notifierEntity);
|
|
|
} else {
|
|
|
notificationRepository.save(notification);
|
|
|
}
|
|
|
@@ -202,6 +210,18 @@ public class AppOrchestrateService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public List<AppToBuild> buildList() {
|
|
|
+ List list = appDAO.findBuildApps();
|
|
|
+ List<AppToBuild> appToBuilds = new ArrayList<>();
|
|
|
+ list.forEach(object -> {
|
|
|
+ Object[] objects = (Object[]) object;
|
|
|
+ appToBuilds.add(new AppToBuild(String.valueOf(objects[0]), String.valueOf(objects[1]),
|
|
|
+ String.valueOf(objects[2]), String.valueOf(objects[3])));
|
|
|
+ });
|
|
|
+
|
|
|
+ return appToBuilds;
|
|
|
+ }
|
|
|
+
|
|
|
public boolean modify(int type, String json) {
|
|
|
switch (type) {
|
|
|
case 1:
|
|
|
@@ -233,6 +253,13 @@ public class AppOrchestrateService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * TODO 除了删除数据库中所有与应用相关的数据,还应删除文件系统和 docker 中与应用相关的数据
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * @date 2020-05-22 下午4:52
|
|
|
+ */
|
|
|
public void delete(int type, String appId) {
|
|
|
switch (type) {
|
|
|
case 1:
|