forked from TencentBlueKing/bk-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug:研发商店组件审核发布时录入T_STORE_RELEASE表的首次发布人有误 TencentBlueKing#11366
- Loading branch information
Showing
6 changed files
with
200 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...ain/kotlin/com/tencent/devops/store/common/service/StoreComponentDataCorrectionService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.tencent.devops.store.common.service | ||
|
||
abstract class StoreComponentDataCorrectionService { | ||
|
||
abstract fun updateComponentFirstPublisher() | ||
|
||
} |
112 changes: 112 additions & 0 deletions
112
...m/tencent/devops/store/common/service/impl/StoreCoreComponentDataCorrectionServiceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package com.tencent.devops.store.common.service.impl | ||
|
||
import com.tencent.devops.store.atom.dao.MarketAtomDao | ||
import com.tencent.devops.store.common.dao.StoreReleaseDao | ||
import com.tencent.devops.store.common.service.StoreComponentDataCorrectionService | ||
import com.tencent.devops.store.image.dao.MarketImageDao | ||
import com.tencent.devops.store.pojo.common.enums.StoreTypeEnum | ||
import com.tencent.devops.store.template.dao.MarketTemplateDao | ||
import org.jooq.DSLContext | ||
import org.jooq.impl.DSL | ||
import org.slf4j.LoggerFactory | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.stereotype.Service | ||
|
||
|
||
@Service | ||
class StoreCoreComponentDataCorrectionServiceImpl : StoreComponentDataCorrectionService() { | ||
@Autowired | ||
lateinit var dslContext: DSLContext | ||
|
||
@Autowired | ||
lateinit var atomDao: MarketAtomDao | ||
|
||
@Autowired | ||
lateinit var templateDao: MarketTemplateDao | ||
|
||
@Autowired | ||
lateinit var imageDao: MarketImageDao | ||
|
||
|
||
@Autowired | ||
lateinit var storeReleaseDao: StoreReleaseDao | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
override fun updateComponentFirstPublisher() { | ||
|
||
try { | ||
val atomList = atomDao.listByAtomCode(dslContext)?.map { Component(it.atomCode, it.modifier) } | ||
updateFirstPublisherIfNecessary(StoreTypeEnum.ATOM, atomList, storeReleaseDao, dslContext) | ||
|
||
val templateList = templateDao.listByTemplateCode(dslContext)?.map { Component(it.templateCode, it.modifier) } | ||
updateFirstPublisherIfNecessary(StoreTypeEnum.TEMPLATE, templateList, storeReleaseDao, dslContext) | ||
|
||
val imageList = imageDao.listByImageCode(dslContext)?.map { Component(it.imageCode, it.modifier) } | ||
updateFirstPublisherIfNecessary(StoreTypeEnum.IMAGE, imageList, storeReleaseDao, dslContext) | ||
}catch (e: Exception){ | ||
logger.info("updateComponentFirstPublisher error:${e.message}") | ||
throw RuntimeException("updateComponentFirstPublisher error") | ||
} | ||
|
||
} | ||
|
||
|
||
fun updateFirstPublisherIfNecessary( | ||
storeTypeEnum: StoreTypeEnum, | ||
list: List<Component>?, | ||
dao: StoreReleaseDao, | ||
dslContext: DSLContext | ||
) { | ||
|
||
if (!list.isNullOrEmpty()) { | ||
val codes = list.map { it.code } | ||
val storeReleaseList = storeReleaseDao.selectStoreReleaseInfo( | ||
dslContext, | ||
codes, | ||
storeTypeEnum.type.toByte() | ||
) | ||
|
||
if (!storeReleaseList.isNullOrEmpty()) { | ||
list.forEach { | ||
val storeRelease = storeReleaseList.find { storeRelease -> storeRelease.storeCode == it.code && storeRelease.storeType == storeTypeEnum.type.toByte()} | ||
if (storeRelease != null && it.modifier != storeRelease.firstPubCreator) { | ||
dslContext.transaction { configuration -> | ||
val transactionContext = DSL.using(configuration) | ||
dao.updateComponentFirstPublisher( | ||
dslContext = transactionContext, | ||
storeCode = it.code, | ||
storeType = storeTypeEnum.type.toByte(), | ||
firstPublisher = it.modifier | ||
) | ||
} | ||
|
||
} | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
|
||
class Component( | ||
val code: String, | ||
val modifier: String | ||
) | ||
|
||
|
||
companion object { | ||
private val logger = LoggerFactory.getLogger(StoreCoreComponentDataCorrectionServiceImpl::class.java) | ||
} | ||
|
||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters