Skip to content

Commit

Permalink
pref:研发商店通用化接口封装优化 TencentBlueKing#11049
Browse files Browse the repository at this point in the history
  • Loading branch information
carlyin0801 committed Oct 10, 2024
1 parent c770eba commit 9f8ca5a
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
*
* BK-CI 蓝鲸持续集成平台 is licensed under the MIT license.
*
* A copy of the MIT License is included in this file.
*
*
* Terms of the MIT License:
* ---------------------------------------------------
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
* the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.tencent.devops.store.common.handler

import com.tencent.devops.store.common.service.StoreBaseCreateService
import com.tencent.devops.store.pojo.common.handler.Handler
import com.tencent.devops.store.pojo.common.publication.StoreCreateRequest
import org.springframework.stereotype.Service

@Service
class StoreCreatePreBusHandler(
private val storeBaseCreateService: StoreBaseCreateService
) : Handler<StoreCreateRequest> {

override fun canExecute(handlerRequest: StoreCreateRequest): Boolean {
return true
}

override fun execute(handlerRequest: StoreCreateRequest) {
// 执行前置业务
storeBaseCreateService.doStoreCreatePreBus(handlerRequest)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ interface StoreBaseCreateService {
storeCreateRequest: StoreCreateRequest
)

/**
* 执行新增组件请求前置业务
* @param storeCreateRequest 新增组件请求报文
*/
fun doStoreCreatePreBus(
storeCreateRequest: StoreCreateRequest
)

/**
* 持久化新增组件数据
* @param storeCreateRequest 新增组件请求报文
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,21 @@ package com.tencent.devops.store.common.service
import com.tencent.devops.store.pojo.common.enums.StoreStatusEnum
import com.tencent.devops.store.pojo.common.enums.StoreTypeEnum
import com.tencent.devops.store.pojo.common.publication.ReleaseProcessItem
import com.tencent.devops.store.pojo.common.publication.StoreCreateRequest
import com.tencent.devops.store.pojo.common.publication.StorePkgEnvInfo
import com.tencent.devops.store.pojo.common.publication.StoreRunPipelineParam
import com.tencent.devops.store.pojo.common.publication.StoreUpdateRequest

interface StoreReleaseSpecBusService {

/**
* 执行新增组件请求前置业务
* @param storeCreateRequest 新增组件请求报文
*/
fun doStoreCreatePreBus(
storeCreateRequest: StoreCreateRequest
)

/**
* 对更新组件请求参数进行国际化转换个性化逻辑
* @param storeUpdateRequest 更新组件请求报文
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID_DEFAULT_VALUE
import com.tencent.devops.common.api.constant.CommonMessageCode
import com.tencent.devops.common.api.constant.INIT_VERSION
import com.tencent.devops.common.api.exception.ErrorCodeException
import com.tencent.devops.common.service.utils.SpringContextUtil
import com.tencent.devops.store.common.dao.StoreBaseEnvExtManageDao
import com.tencent.devops.store.common.dao.StoreBaseEnvManageDao
import com.tencent.devops.store.common.dao.StoreBaseExtManageDao
Expand All @@ -43,7 +44,9 @@ import com.tencent.devops.store.common.dao.StoreMemberDao
import com.tencent.devops.store.common.dao.StoreProjectRelDao
import com.tencent.devops.store.common.dao.StoreStatisticTotalDao
import com.tencent.devops.store.common.service.StoreBaseCreateService
import com.tencent.devops.store.common.service.StoreReleaseSpecBusService
import com.tencent.devops.store.common.utils.StoreReleaseUtils
import com.tencent.devops.store.common.utils.StoreUtils
import com.tencent.devops.store.pojo.common.KEY_STORE_ID
import com.tencent.devops.store.pojo.common.enums.StoreMemberTypeEnum
import com.tencent.devops.store.pojo.common.enums.StoreProjectTypeEnum
Expand Down Expand Up @@ -97,6 +100,12 @@ class StoreBaseCreateServiceImpl @Autowired constructor(
}
}

override fun doStoreCreatePreBus(storeCreateRequest: StoreCreateRequest) {
val storeBaseCreateRequest = storeCreateRequest.baseInfo
val storeType = storeBaseCreateRequest.storeType
getStoreSpecBusService(storeType).doStoreCreatePreBus(storeCreateRequest)
}

override fun doStoreCreateDataPersistent(storeCreateRequest: StoreCreateRequest) {
val storeBaseCreateRequest = storeCreateRequest.baseInfo
val storeType = storeBaseCreateRequest.storeType
Expand Down Expand Up @@ -157,6 +166,13 @@ class StoreBaseCreateServiceImpl @Autowired constructor(
}
}

private fun getStoreSpecBusService(storeType: StoreTypeEnum): StoreReleaseSpecBusService {
return SpringContextUtil.getBean(
StoreReleaseSpecBusService::class.java,
StoreUtils.getReleaseSpecBusServiceBeanName(storeType)
)
}

private fun initStoreData(
context: DSLContext,
storeCode: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import com.tencent.devops.store.common.dao.StoreVersionLogDao
import com.tencent.devops.store.common.handler.StoreCreateDataPersistHandler
import com.tencent.devops.store.common.handler.StoreCreateHandlerChain
import com.tencent.devops.store.common.handler.StoreCreateParamCheckHandler
import com.tencent.devops.store.common.handler.StoreCreatePreBusHandler
import com.tencent.devops.store.common.handler.StoreUpdateDataPersistHandler
import com.tencent.devops.store.common.handler.StoreUpdateHandlerChain
import com.tencent.devops.store.common.handler.StoreUpdateParamCheckHandler
Expand Down Expand Up @@ -98,6 +99,7 @@ class StoreReleaseServiceImpl @Autowired constructor(
private val storeNotifyService: StoreNotifyService,
private val storePipelineService: StorePipelineService,
private val storeCreateParamCheckHandler: StoreCreateParamCheckHandler,
private val storeCreatePreBusHandler: StoreCreatePreBusHandler,
private val storeCreateDataPersistHandler: StoreCreateDataPersistHandler,
private val storeUpdateParamI18nConvertHandler: StoreUpdateParamI18nConvertHandler,
private val storeUpdateParamCheckHandler: StoreUpdateParamCheckHandler,
Expand All @@ -115,6 +117,7 @@ class StoreReleaseServiceImpl @Autowired constructor(
logger.info("createComponent userId:$userId|storeCreateRequest:$storeCreateRequest")
val handlerList = mutableListOf(
storeCreateParamCheckHandler, // 参数检查处理
storeCreatePreBusHandler, // 前置业务处理
storeCreateDataPersistHandler // 数据持久化处理
)
val bkStoreContext = storeCreateRequest.bkStoreContext
Expand Down

0 comments on commit 9f8ca5a

Please sign in to comment.