From bca3ec272e0f5d28f23835a71e8ece41c241d7e3 Mon Sep 17 00:00:00 2001 From: mingshewhe Date: Mon, 5 Aug 2024 21:17:39 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"bug:=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E5=AE=9E=E4=BE=8B=E5=A4=8D=E5=88=B6=E5=8A=9F=E8=83=BD=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=A4=8D=E5=88=B6=E7=9B=B8=E5=BA=94=E5=AE=9E=E4=BE=8B?= =?UTF-8?q?=E7=9A=84=E5=8F=82=E6=95=B0=E5=80=BC=20#10580"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 0a55a81aebb4b47a29270cede20a2f0469ba727f. --- .../template/UserTemplateInstanceResource.kt | 21 +---------- .../UserTemplateInstanceResourceImpl.kt | 15 -------- .../service/template/TemplateFacadeService.kt | 37 ------------------- 3 files changed, 2 insertions(+), 71 deletions(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/template/UserTemplateInstanceResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/template/UserTemplateInstanceResource.kt index f043ab70888..eb305033a7c 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/template/UserTemplateInstanceResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/template/UserTemplateInstanceResource.kt @@ -38,14 +38,13 @@ import com.tencent.devops.process.pojo.PipelineId import com.tencent.devops.process.pojo.enums.TemplateSortTypeEnum import com.tencent.devops.process.pojo.template.TemplateCompareModelResult import com.tencent.devops.process.pojo.template.TemplateInstanceCreate -import com.tencent.devops.process.pojo.template.TemplateInstancePage import com.tencent.devops.process.pojo.template.TemplateInstanceParams import com.tencent.devops.process.pojo.template.TemplateInstanceUpdate -import com.tencent.devops.process.pojo.template.TemplateModelDetail import com.tencent.devops.process.pojo.template.TemplateOperationRet +import com.tencent.devops.process.pojo.template.TemplateInstancePage +import io.swagger.v3.oas.annotations.tags.Tag import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.Parameter -import io.swagger.v3.oas.annotations.tags.Tag import javax.ws.rs.Consumes import javax.ws.rs.GET import javax.ws.rs.HeaderParam @@ -206,20 +205,4 @@ interface UserTemplateInstanceResource { @QueryParam("desc") desc: Boolean? ): Result - - @Operation(summary = "复制流水线实例") - @GET - @Path("/projects/{projectId}/pipelines/{pipelineId}/copy") - @BkApiPermission([BkApiHandleType.API_NO_AUTH_CHECK]) - fun copyTemplateInstance( - @Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE) - @HeaderParam(AUTH_HEADER_USER_ID) - userId: String, - @Parameter(description = "项目ID", required = true) - @PathParam("projectId") - projectId: String, - @Parameter(description = "流水线ID", required = true) - @PathParam("pipelineId") - pipelineId: String - ): Result } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/template/UserTemplateInstanceResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/template/UserTemplateInstanceResourceImpl.kt index 79c009610e4..58a7efaaedc 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/template/UserTemplateInstanceResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/template/UserTemplateInstanceResourceImpl.kt @@ -38,7 +38,6 @@ import com.tencent.devops.process.pojo.template.TemplateInstanceCreate import com.tencent.devops.process.pojo.template.TemplateInstancePage import com.tencent.devops.process.pojo.template.TemplateInstanceParams import com.tencent.devops.process.pojo.template.TemplateInstanceUpdate -import com.tencent.devops.process.pojo.template.TemplateModelDetail import com.tencent.devops.process.pojo.template.TemplateOperationRet import com.tencent.devops.process.service.template.TemplateFacadeService import org.springframework.beans.factory.annotation.Autowired @@ -166,18 +165,4 @@ class UserTemplateInstanceResourceImpl @Autowired constructor( ) ) } - - override fun copyTemplateInstance( - userId: String, - projectId: String, - pipelineId: String - ): Result { - return Result( - templateFacadeService.copyTemplateInstance( - userId = userId, - projectId = projectId, - pipelineId = pipelineId - ) - ) - } } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/template/TemplateFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/template/TemplateFacadeService.kt index bc4919dc28f..e7bb18cd178 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/template/TemplateFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/template/TemplateFacadeService.kt @@ -2586,43 +2586,6 @@ class TemplateFacadeService @Autowired constructor( return pipelineTemplatePermissionService.enableTemplatePermissionManage(projectId) } - /** - * 复制流水线实例 - * - * 复制流水线参数 - */ - fun copyTemplateInstance( - userId: String, - projectId: String, - pipelineId: String - ): TemplateModelDetail { - val templatePipelineRecord = templatePipelineDao.get(dslContext, projectId, pipelineId) - ?: throw NotFoundException( - I18nUtil.getCodeLanMessage( - messageCode = ERROR_TEMPLATE_NOT_EXISTS, - language = I18nUtil.getLanguage(userId) - ) - ) - val templateModelDetail = - getTemplate(projectId, userId, templatePipelineRecord.templateId, templatePipelineRecord.version) - - val templateParams = (templateModelDetail.template.stages[0].containers[0] as TriggerContainer).templateParams - val templateParamIdMap = templateParams?.map { it.id } ?: emptyList() - - val instanceModel: Model = objectMapper.readValue( - pipelineResourceDao.getVersionModelString(dslContext, projectId, pipelineId, null) - ?: throw ErrorCodeException( - statusCode = Response.Status.NOT_FOUND.statusCode, - errorCode = ProcessMessageCode.ERROR_PIPELINE_MODEL_NOT_EXISTS - ) - ) - val instanceParams = (instanceModel.stages[0].containers[0] as TriggerContainer).params - return templateModelDetail.copy( - // 流水线参数排除模板常量 - params = instanceParams.filterNot { templateParamIdMap.contains(it.id) } - ) - } - companion object { private val logger = LoggerFactory.getLogger(TemplateFacadeService::class.java) private const val INIT_TEMPLATE_NAME = "init"