diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/ScriptServiceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/ScriptServiceImpl.java index ad995ed95f..021f3c62aa 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/ScriptServiceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/ScriptServiceImpl.java @@ -293,7 +293,6 @@ public ScriptDTO saveScript(String operator, Long appId, ScriptDTO script) throw script.setStatus(JobResourceStatusEnum.DRAFT.getValue()); Long scriptVersionId = script.getScriptVersionId(); - String scriptId = script.getId(); if (StringUtils.isNotBlank(script.getId())) { // 更新当前版本 if (script.getScriptVersionId() != null && script.getScriptVersionId() > 0) { @@ -314,6 +313,7 @@ public ScriptDTO saveScript(String operator, Long appId, ScriptDTO script) throw throw new AlreadyExistsException(ErrorCode.SCRIPT_VERSION_NAME_EXIST); } scriptVersionId = scriptDAO.saveScriptVersion(script); + script.setScriptVersionId(scriptVersionId); scriptDAO.updateScript(script); } } else { @@ -323,17 +323,13 @@ public ScriptDTO saveScript(String operator, Long appId, ScriptDTO script) throw log.warn("The script name:{} is exist for app:{}", script.getName(), targetAppId); throw new AlreadyExistsException(ErrorCode.SCRIPT_NAME_DUPLICATE); } - scriptId = JobUUID.getUUID(); - script.setId(scriptId); + script.setId(JobUUID.getUUID()); scriptDAO.saveScript(script); scriptVersionId = scriptDAO.saveScriptVersion(script); + script.setScriptVersionId(scriptVersionId); + saveScriptTags(appId, script); } - script.setId(scriptId); - script.setScriptVersionId(scriptVersionId); - - saveScriptTags(appId, script); - return scriptDAO.getScriptVersionById(scriptVersionId); }