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"