From a32ed812aa0fe5ffced3e96780d0df6c5c22aadc Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Mon, 27 Oct 2025 18:06:04 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-?= =?UTF-8?q?=E8=B6=85=E7=BA=A7=E6=B5=81=E6=B0=B4=E7=BA=BF=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=95=B4=E4=BD=93=E4=BF=9D=E5=AD=98=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1541385189031936]后端-超级流水线作业整体保存校验 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1541385189031936 --- .../deploy/api/pipeline/GetPipelineApi.java | 49 ++++++++++++ .../deploy/api/pipeline/SavePipelineApi.java | 80 ++++++++++++++++++- .../dao/mapper/DeployAppConfigMapper.java | 2 + .../dao/mapper/DeployAppConfigMapper.xml | 22 +++++ 4 files changed, 152 insertions(+), 1 deletion(-) diff --git a/src/main/java/neatlogic/module/deploy/api/pipeline/GetPipelineApi.java b/src/main/java/neatlogic/module/deploy/api/pipeline/GetPipelineApi.java index b8bfdbdc..d9ca7ef9 100644 --- a/src/main/java/neatlogic/module/deploy/api/pipeline/GetPipelineApi.java +++ b/src/main/java/neatlogic/module/deploy/api/pipeline/GetPipelineApi.java @@ -17,17 +17,27 @@ package neatlogic.module.deploy.api.pipeline; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.auth.core.AuthAction; +import neatlogic.framework.autoexec.dto.AutoexecParamVo; import neatlogic.framework.common.constvalue.ApiParamType; import neatlogic.framework.deploy.auth.DEPLOY_BASE; +import neatlogic.framework.deploy.dto.app.DeployAppConfigVo; +import neatlogic.framework.deploy.dto.app.DeployPipelineConfigVo; +import neatlogic.framework.deploy.dto.pipeline.PipelineGroupVo; +import neatlogic.framework.deploy.dto.pipeline.PipelineJobTemplateVo; +import neatlogic.framework.deploy.dto.pipeline.PipelineLaneVo; import neatlogic.framework.deploy.dto.pipeline.PipelineVo; import neatlogic.framework.deploy.exception.pipeline.DeployPipelineNotFoundEditTargetException; import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import neatlogic.module.deploy.dao.mapper.DeployAppConfigMapper; import neatlogic.module.deploy.dao.mapper.DeployPipelineMapper; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; @Service @AuthAction(action = DEPLOY_BASE.class) @@ -36,6 +46,8 @@ public class GetPipelineApi extends PrivateApiComponentBase { @Resource private DeployPipelineMapper deployPipelineMapper; + @Resource + private DeployAppConfigMapper deployAppConfigMapper; @Override public String getName() { @@ -63,6 +75,43 @@ public class GetPipelineApi extends PrivateApiComponentBase { if (pipelineVo == null) { throw new DeployPipelineNotFoundEditTargetException(id); } + List appConfigList = new ArrayList<>(); + List appSystemIdList = new ArrayList<>(); + List laneList = pipelineVo.getLaneList(); + if (CollectionUtils.isNotEmpty(laneList)) { + for (PipelineLaneVo pipelineLaneVo : laneList) { + List groupList = pipelineLaneVo.getGroupList(); + if (CollectionUtils.isNotEmpty(groupList)) { + for (PipelineGroupVo pipelineGroupVo : groupList) { + List jobTemplateList = pipelineGroupVo.getJobTemplateList(); + if (CollectionUtils.isNotEmpty(jobTemplateList)) { + for (PipelineJobTemplateVo pipelineJobTemplateVo : jobTemplateList) { + Long appSystemId = pipelineJobTemplateVo.getAppSystemId(); + if (appSystemId != null && !appSystemIdList.contains(appSystemId)) { + appSystemIdList.add(appSystemId); + } + } + } + } + } + } + } + if (CollectionUtils.isNotEmpty(appSystemIdList)) { + appConfigList = deployAppConfigMapper.getAppConfigListByAppSystemIdList(appSystemIdList); + if (CollectionUtils.isNotEmpty(appConfigList)) { + for (DeployAppConfigVo deployAppConfigVo : appConfigList) { + DeployPipelineConfigVo newConfig = new DeployPipelineConfigVo(); + List runtimeParamList = new ArrayList<>(); + DeployPipelineConfigVo config = deployAppConfigVo.getConfig(); + if (config != null && CollectionUtils.isNotEmpty(config.getRuntimeParamList())) { + runtimeParamList = config.getRuntimeParamList(); + } + newConfig.setRuntimeParamList(runtimeParamList); + deployAppConfigVo.setConfig(newConfig); + } + } + } + pipelineVo.setAppConfigList(appConfigList); return pipelineVo; } diff --git a/src/main/java/neatlogic/module/deploy/api/pipeline/SavePipelineApi.java b/src/main/java/neatlogic/module/deploy/api/pipeline/SavePipelineApi.java index 38d141fd..3192588f 100644 --- a/src/main/java/neatlogic/module/deploy/api/pipeline/SavePipelineApi.java +++ b/src/main/java/neatlogic/module/deploy/api/pipeline/SavePipelineApi.java @@ -20,28 +20,34 @@ import com.alibaba.fastjson.JSONObject; import neatlogic.framework.asynchronization.threadlocal.UserContext; import neatlogic.framework.auth.core.AuthAction; import neatlogic.framework.auth.core.AuthActionChecker; +import neatlogic.framework.autoexec.dto.AutoexecParamVo; import neatlogic.framework.common.constvalue.ApiParamType; import neatlogic.framework.deploy.auth.DEPLOY_BASE; import neatlogic.framework.deploy.auth.PIPELINE_MODIFY; import neatlogic.framework.deploy.constvalue.DeployAppConfigAction; import neatlogic.framework.deploy.constvalue.PipelineType; +import neatlogic.framework.deploy.dto.app.DeployAppConfigVo; +import neatlogic.framework.deploy.dto.app.DeployPipelineConfigVo; import neatlogic.framework.deploy.dto.pipeline.*; import neatlogic.framework.deploy.exception.DeployPipelineNotFoundException; import neatlogic.framework.deploy.exception.DeployScheduleNameRepeatException; +import neatlogic.framework.deploy.exception.pipeline.DeployPipelineParamCannotBeEmptyException; import neatlogic.framework.dto.FieldValidResultVo; import neatlogic.framework.exception.type.PermissionDeniedException; import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.IValid; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import neatlogic.module.deploy.dao.mapper.DeployAppConfigMapper; import neatlogic.module.deploy.dao.mapper.DeployPipelineMapper; import neatlogic.module.deploy.service.DeployAppAuthorityService; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.Objects; +import java.util.*; @Service @Transactional @@ -53,6 +59,9 @@ public class SavePipelineApi extends PrivateApiComponentBase { @Resource private DeployAppAuthorityService deployAppAuthorityService; + @Resource + private DeployAppConfigMapper deployAppConfigMapper; + @Override public String getName() { return "保存超级流水线"; @@ -95,6 +104,7 @@ public class SavePipelineApi extends PrivateApiComponentBase { } else if (Objects.equals(type, PipelineType.APPSYSTEM.getValue())) { deployAppAuthorityService.checkOperationAuth(pipelineVo.getAppSystemId(), DeployAppConfigAction.PIPELINE); } + verifyPipelineConfig(pipelineVo); if (id == null) { pipelineVo.setFcu(UserContext.get().getUserUuid(true)); pipelineMapper.insertPipeline(pipelineVo); @@ -155,4 +165,72 @@ public class SavePipelineApi extends PrivateApiComponentBase { }; } + private void verifyPipelineConfig(PipelineVo pipelineVo) { + List appSystemIdList = new ArrayList<>(); + List laneList = pipelineVo.getLaneList(); + if (CollectionUtils.isNotEmpty(laneList)) { + for (PipelineLaneVo pipelineLaneVo : laneList) { + List groupList = pipelineLaneVo.getGroupList(); + if (CollectionUtils.isNotEmpty(groupList)) { + for (PipelineGroupVo pipelineGroupVo : groupList) { + List jobTemplateList = pipelineGroupVo.getJobTemplateList(); + if (CollectionUtils.isNotEmpty(jobTemplateList)) { + for (PipelineJobTemplateVo pipelineJobTemplateVo : jobTemplateList) { + Long appSystemId = pipelineJobTemplateVo.getAppSystemId(); + if (appSystemId != null && !appSystemIdList.contains(appSystemId)) { + appSystemIdList.add(appSystemId); + } + } + } + } + } + } + } + if (CollectionUtils.isNotEmpty(appSystemIdList)) { + Map> appSystemId2RuntimeParamListMap = new HashMap<>(); + List appConfigList = deployAppConfigMapper.getAppConfigListByAppSystemIdList(appSystemIdList); + for (DeployAppConfigVo deployAppConfigVo : appConfigList) { + DeployPipelineConfigVo config = deployAppConfigVo.getConfig(); + if (config != null && CollectionUtils.isNotEmpty(config.getRuntimeParamList())) { + appSystemId2RuntimeParamListMap.put(deployAppConfigVo.getAppSystemId(), config.getRuntimeParamList()); + } + } + if (CollectionUtils.isNotEmpty(laneList)) { + for (int i = 0; i < laneList.size(); i++) { + PipelineLaneVo laneVo = laneList.get(i); + List groupList = laneVo.getGroupList(); + if (CollectionUtils.isNotEmpty(groupList)) { + for (int j = 0; j < groupList.size(); j++) { + PipelineGroupVo groupVo = groupList.get(j); + List jobTemplateList = groupVo.getJobTemplateList(); + if (CollectionUtils.isNotEmpty(jobTemplateList)) { + for (int k = 0; k < jobTemplateList.size(); k++) { + PipelineJobTemplateVo jobVo = jobTemplateList.get(k); + Long appSystemId = jobVo.getAppSystemId(); + List runtimeParamList = appSystemId2RuntimeParamListMap.get(appSystemId); + if (CollectionUtils.isNotEmpty(runtimeParamList)) { + JSONObject param = null; + JSONObject config = jobVo.getConfig(); + if (MapUtils.isNotEmpty(config)) { + param = config.getJSONObject("param"); + } + if (param == null) { + param = new JSONObject(); + } + for (AutoexecParamVo runtimeParam : runtimeParamList) { + if (Objects.equals(runtimeParam.getIsRequired(), 1)) { + if (!param.containsKey(runtimeParam.getKey())) { + throw new DeployPipelineParamCannotBeEmptyException(i + 1, j + 1, k + 1, runtimeParam.getName(), runtimeParam.getKey()); + } + } + } + } + } + } + } + } + } + } + } + } } diff --git a/src/main/java/neatlogic/module/deploy/dao/mapper/DeployAppConfigMapper.java b/src/main/java/neatlogic/module/deploy/dao/mapper/DeployAppConfigMapper.java index 5f1f9dbf..0d2f920f 100644 --- a/src/main/java/neatlogic/module/deploy/dao/mapper/DeployAppConfigMapper.java +++ b/src/main/java/neatlogic/module/deploy/dao/mapper/DeployAppConfigMapper.java @@ -96,6 +96,8 @@ public interface DeployAppConfigMapper extends IDeployAppConfigCrossoverMapper { List getAppConfigAppSystemIdListByAppSystemIdList(List list); + List getAppConfigListByAppSystemIdList(List list); + List getAppConfigUserAppSystemIdList(@Param("userUuid") String userUuid, @Param("appSystemIdList") List appSystemIdList); List getAppEnvAutoConfigBySystemIdAndModuleIdAndEnvId(@Param("systemId") Long systemId, @Param("moduleId") Long moduleId, @Param("envId") Long envId); diff --git a/src/main/java/neatlogic/module/deploy/dao/mapper/DeployAppConfigMapper.xml b/src/main/java/neatlogic/module/deploy/dao/mapper/DeployAppConfigMapper.xml index a4d6e3ec..68c33089 100644 --- a/src/main/java/neatlogic/module/deploy/dao/mapper/DeployAppConfigMapper.xml +++ b/src/main/java/neatlogic/module/deploy/dao/mapper/DeployAppConfigMapper.xml @@ -1087,6 +1087,28 @@ along with this program. If not, see .--> + +