diff --git a/src/backend/ci/core/store/api-store/src/main/kotlin/com/tencent/devops/store/api/common/OpStorePublishersResource.kt b/src/backend/ci/core/store/api-store/src/main/kotlin/com/tencent/devops/store/api/common/OpStorePublishersResource.kt index 0a8df1d9f3c..89418989001 100644 --- a/src/backend/ci/core/store/api-store/src/main/kotlin/com/tencent/devops/store/api/common/OpStorePublishersResource.kt +++ b/src/backend/ci/core/store/api-store/src/main/kotlin/com/tencent/devops/store/api/common/OpStorePublishersResource.kt @@ -27,13 +27,18 @@ package com.tencent.devops.store.api.common +import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID import com.tencent.devops.common.api.pojo.Result +import com.tencent.devops.store.pojo.common.enums.StoreTypeEnum 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.HeaderParam import javax.ws.rs.PUT import javax.ws.rs.Path import javax.ws.rs.Produces +import javax.ws.rs.QueryParam import javax.ws.rs.core.MediaType @Tag(name = "OP_STORE_PUBLISHERS", description = "OP-研发商店-发布者") @@ -46,4 +51,22 @@ interface OpStorePublishersResource { @PUT @Path("/refresh/person") fun refreshPersonPublisherGroup(): Result + + @Operation(summary = "修改组件的首次发布人") + @PUT + @Path("/updateComponentFirstPublisher") + fun updateComponentFirstPublisher( + @Parameter(description = "userId", required = true) + @HeaderParam(AUTH_HEADER_USER_ID) + userId: String, + @Parameter(description = "store组件代码", required = true) + @QueryParam("storeCode") + storeCode: String, + @Parameter(description = "组件类型", required = true) + @QueryParam("storeType") + storeType: StoreTypeEnum, + @Parameter(description = "首次发布人", required = true) + @QueryParam("firstPublisher") + firstPublisher: String + ): Result } diff --git a/src/backend/ci/core/store/api-store/src/main/kotlin/com/tencent/devops/store/pojo/atom/AtomReleaseRequest.kt b/src/backend/ci/core/store/api-store/src/main/kotlin/com/tencent/devops/store/pojo/atom/AtomReleaseRequest.kt index bcdcea2fc28..b19af80bee8 100644 --- a/src/backend/ci/core/store/api-store/src/main/kotlin/com/tencent/devops/store/pojo/atom/AtomReleaseRequest.kt +++ b/src/backend/ci/core/store/api-store/src/main/kotlin/com/tencent/devops/store/pojo/atom/AtomReleaseRequest.kt @@ -45,5 +45,8 @@ data class AtomReleaseRequest( @get:Schema(title = "代码库哈希ID") val repositoryHashId: String? = null, @get:Schema(title = "代码库分支") - val branch: String? = null -) + val branch: String? = null, + @get:Schema(title = "发布人") + val publisher: String? = null, + + ) diff --git a/src/backend/ci/core/store/api-store/src/main/kotlin/com/tencent/devops/store/pojo/common/publication/StoreReleaseRequest.kt b/src/backend/ci/core/store/api-store/src/main/kotlin/com/tencent/devops/store/pojo/common/publication/StoreReleaseRequest.kt index d1a8ddfcb59..4cf1c66f0bf 100644 --- a/src/backend/ci/core/store/api-store/src/main/kotlin/com/tencent/devops/store/pojo/common/publication/StoreReleaseRequest.kt +++ b/src/backend/ci/core/store/api-store/src/main/kotlin/com/tencent/devops/store/pojo/common/publication/StoreReleaseRequest.kt @@ -45,5 +45,7 @@ data class StoreReleaseRequest( @get:Schema(title = "组件状态") val status: StoreStatusEnum, @get:Schema(title = "发布类型") - val releaseType: ReleaseTypeEnum + val releaseType: ReleaseTypeEnum, + @get:Schema(title = "发布人") + val publisher: String? = null ) diff --git a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/atom/service/impl/AtomReleaseServiceImpl.kt b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/atom/service/impl/AtomReleaseServiceImpl.kt index f001714dd31..63a173ba4b2 100644 --- a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/atom/service/impl/AtomReleaseServiceImpl.kt +++ b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/atom/service/impl/AtomReleaseServiceImpl.kt @@ -1060,7 +1060,7 @@ abstract class AtomReleaseServiceImpl @Autowired constructor() : AtomReleaseServ storeReleaseCreateRequest = StoreReleaseCreateRequest( storeCode = atomCode, storeType = StoreTypeEnum.ATOM, - latestUpgrader = userId, + latestUpgrader = atomReleaseRequest.publisher ?: userId, latestUpgradeTime = pubTime ) ) diff --git a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/atom/service/impl/OpAtomServiceImpl.kt b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/atom/service/impl/OpAtomServiceImpl.kt index 91708a5bcd8..81b4e714974 100644 --- a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/atom/service/impl/OpAtomServiceImpl.kt +++ b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/atom/service/impl/OpAtomServiceImpl.kt @@ -348,7 +348,8 @@ class OpAtomServiceImpl @Autowired constructor( atomStatus = atomStatus, releaseType = releaseType, repositoryHashId = atom.repositoryHashId, - branch = atom.branch + branch = atom.branch, + publisher = atom.publisher ) ) } else { diff --git a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/dao/StoreReleaseDao.kt b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/dao/StoreReleaseDao.kt index 526336d78d8..ba8f10909e5 100644 --- a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/dao/StoreReleaseDao.kt +++ b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/dao/StoreReleaseDao.kt @@ -91,4 +91,21 @@ class StoreReleaseDao { .execute() } } + + fun updateComponentFirstPublisher( + dslContext: DSLContext, + userId: String, + storeCode: String, + storeType: Byte, + firstPublisher: String + ) { + with(TStoreRelease.T_STORE_RELEASE) { + dslContext.update(this) + .set(FIRST_PUB_CREATOR, firstPublisher) + .set(MODIFIER, userId) + .where(STORE_CODE.eq(storeCode)) + .and(STORE_TYPE.eq(storeType)) + .execute() + } + } } diff --git a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/resources/OpStorePublishersResourceImpl.kt b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/resources/OpStorePublishersResourceImpl.kt index 165808fff3c..f31701c33df 100644 --- a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/resources/OpStorePublishersResourceImpl.kt +++ b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/resources/OpStorePublishersResourceImpl.kt @@ -31,6 +31,7 @@ import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.web.RestResource import com.tencent.devops.store.api.common.OpStorePublishersResource import com.tencent.devops.store.common.service.PublishersDataService +import com.tencent.devops.store.pojo.common.enums.StoreTypeEnum @RestResource class OpStorePublishersResourceImpl constructor( @@ -40,4 +41,13 @@ class OpStorePublishersResourceImpl constructor( override fun refreshPersonPublisherGroup(): Result { return Result(publishersDataService.refreshPersonPublisherGroup()) } + + override fun updateComponentFirstPublisher( + userId: String, + storeCode: String, + storeType: StoreTypeEnum, + firstPublisher: String + ): Result { + return Result(publishersDataService.updateComponentFirstPublisher(userId, storeCode, storeType, firstPublisher)) + } } diff --git a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/PublishersDataService.kt b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/PublishersDataService.kt index 2b479c6dc45..1a20956ee1a 100644 --- a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/PublishersDataService.kt +++ b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/PublishersDataService.kt @@ -74,4 +74,14 @@ interface PublishersDataService { * 更新研发商店个人发布者组织架构信息 */ fun refreshPersonPublisherGroup(): Boolean + + /** + * 修改组件首个发布人 + */ + fun updateComponentFirstPublisher( + userId: String, + storeCode: String, + storeType: StoreTypeEnum, + firstPublisher: String + ): Boolean } diff --git a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/OpStoreComponentServiceImpl.kt b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/OpStoreComponentServiceImpl.kt index 6298deeb27e..89efcb1bd62 100644 --- a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/OpStoreComponentServiceImpl.kt +++ b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/OpStoreComponentServiceImpl.kt @@ -115,7 +115,8 @@ class OpStoreComponentServiceImpl @Autowired constructor( storeType = storeType, version = version, status = storeStatus, - releaseType = releaseType + releaseType = releaseType, + publisher = record.publisher ) ) } diff --git a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/PublishersDataServiceImpl.kt b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/PublishersDataServiceImpl.kt index b55c70007f1..f71fd2ffb9d 100644 --- a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/PublishersDataServiceImpl.kt +++ b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/PublishersDataServiceImpl.kt @@ -44,6 +44,7 @@ import com.tencent.devops.store.common.dao.PublishersDao import com.tencent.devops.store.common.dao.StoreDockingPlatformDao import com.tencent.devops.store.common.dao.StoreDockingPlatformErrorCodeDao import com.tencent.devops.store.common.dao.StoreMemberDao +import com.tencent.devops.store.common.dao.StoreReleaseDao import com.tencent.devops.store.common.service.PublishersDataService import com.tencent.devops.store.common.service.StoreUserService import com.tencent.devops.store.constant.StoreMessageCode.GET_INFO_NO_PERMISSION @@ -70,7 +71,8 @@ class PublishersDataServiceImpl @Autowired constructor( private val storeDockingPlatformDao: StoreDockingPlatformDao, private val storeMemberDao: StoreMemberDao, private val storeUserService: StoreUserService, - private val storeDockingPlatformErrorCodeDao: StoreDockingPlatformErrorCodeDao + private val storeDockingPlatformErrorCodeDao: StoreDockingPlatformErrorCodeDao, + private val storeReleaseDao: StoreReleaseDao ) : PublishersDataService { private val executorService = Executors.newSingleThreadExecutor() @@ -347,6 +349,22 @@ class PublishersDataServiceImpl @Autowired constructor( return true } + override fun updateComponentFirstPublisher( + userId: String, + storeCode: String, + storeType: StoreTypeEnum, + firstPublisher: String + ): Boolean { + storeReleaseDao.updateComponentFirstPublisher( + dslContext, + userId, + storeCode, + storeType.type.toByte(), + firstPublisher + ) + return true + } + private fun getPublisherDeptInfo(userDeptDetail: UserDeptDetail): PublisherDeptInfo { userDeptDetail.let { val publisherDeptInfo = PublisherDeptInfo( diff --git a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/StoreReleaseServiceImpl.kt b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/StoreReleaseServiceImpl.kt index 07401c0c5ce..5f810864db8 100644 --- a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/StoreReleaseServiceImpl.kt +++ b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/StoreReleaseServiceImpl.kt @@ -363,7 +363,7 @@ class StoreReleaseServiceImpl @Autowired constructor( storeReleaseCreateRequest = StoreReleaseCreateRequest( storeCode = storeCode, storeType = storeType, - latestUpgrader = userId, + latestUpgrader = storeReleaseRequest.publisher ?: userId, latestUpgradeTime = pubTime ) )