|
|
@@ -5,8 +5,11 @@ import cn.reghao.autodop.dmaster.common.db.PageList;
|
|
|
import cn.reghao.autodop.dmaster.app.entity.log.BuildDeployApp;
|
|
|
import cn.reghao.autodop.dmaster.app.entity.config.orchestration.AppOrchestration;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.orchestration.AppOrchestrationRepository;
|
|
|
-import cn.reghao.autodop.dmaster.app.service.crud.log.BuildDeployAppCrudService;
|
|
|
+import cn.reghao.autodop.dmaster.app.service.crud.BuildDeployAppCrudService;
|
|
|
import cn.reghao.autodop.dmaster.app.service.crud.SharedEntityChecker;
|
|
|
+import org.springframework.cache.annotation.CacheConfig;
|
|
|
+import org.springframework.cache.annotation.CacheEvict;
|
|
|
+import org.springframework.cache.annotation.CachePut;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
@@ -18,6 +21,7 @@ import java.time.LocalDateTime;
|
|
|
* @author reghao
|
|
|
* @date 2020-11-10 21:58:00
|
|
|
*/
|
|
|
+//@CacheConfig(cacheNames = {"appCache"})
|
|
|
@Service
|
|
|
public class AppCrudService implements CrudOps<AppOrchestration> {
|
|
|
private AppOrchestrationRepository appRepository;
|
|
|
@@ -32,6 +36,41 @@ public class AppCrudService implements CrudOps<AppOrchestration> {
|
|
|
this.buildDeployAppCrudService = buildDeployAppCrudService;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void add(AppOrchestration app) throws Exception {
|
|
|
+ checkSharedEntity(app);
|
|
|
+ AppOrchestration appEntity = appRepository.findByIsDeleteFalseAndAppId(app.getAppId());
|
|
|
+ if (appEntity == null) {
|
|
|
+ app.setIsDelete(false);
|
|
|
+ appRepository.save(app);
|
|
|
+ buildDeployAppCrudService.add(BuildDeployApp.of(app));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void update(AppOrchestration app) throws Exception {
|
|
|
+ checkSharedEntity(app);
|
|
|
+ AppOrchestration appEntity = appRepository.findByIsDeleteFalseAndAppId(app.getAppId());
|
|
|
+ if (appEntity != null) {
|
|
|
+ app.setId(appEntity.getId());
|
|
|
+ app.setCreateTime(appEntity.getCreateTime());
|
|
|
+ app.setUpdateTime(LocalDateTime.now());
|
|
|
+ app.setIsDelete(false);
|
|
|
+ appRepository.save(app);
|
|
|
+ buildDeployAppCrudService.update(BuildDeployApp.of(app));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkSharedEntity(AppOrchestration app) throws Exception {
|
|
|
+ if (app.getProj() != null) {
|
|
|
+ sharedEntityChecker.checkAndSetProj(app);
|
|
|
+ } else {
|
|
|
+ sharedEntityChecker.checkAndSetBuildConfig(app.getBuildConfig());
|
|
|
+ }
|
|
|
+ sharedEntityChecker.checkAndSetNotifier(app);
|
|
|
+ sharedEntityChecker.checkAndSetRole(app);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void addOrUpdate(AppOrchestration app) throws Exception {
|
|
|
if (app.getProj() != null) {
|
|
|
@@ -90,6 +129,7 @@ public class AppCrudService implements CrudOps<AppOrchestration> {
|
|
|
app.setUpdateTime(null);
|
|
|
}
|
|
|
|
|
|
+ //@Cacheable("appList")
|
|
|
@Override
|
|
|
public PageList<AppOrchestration> getByPage(int page, int size, String env) {
|
|
|
// 默认按更新时间倒序
|
|
|
@@ -104,6 +144,7 @@ public class AppCrudService implements CrudOps<AppOrchestration> {
|
|
|
return pageList;
|
|
|
}
|
|
|
|
|
|
+ //@CacheEvict(cacheNames = { "app" }, key = "#uniqueKey")
|
|
|
@Override
|
|
|
public void delete(String uniqueKey) throws Exception {
|
|
|
AppOrchestration appEntity = appRepository.findByIsDeleteFalseAndAppId(uniqueKey);
|