From 842d4c83bccc0c03ce44fe2cc96bd29d40ca8fae Mon Sep 17 00:00:00 2001 From: carlyin <449036249@qq.com> Date: Fri, 13 Aug 2021 21:15:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E3=80=90=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E3=80=91=E6=94=AF=E6=8C=81=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E5=A4=A7=E7=89=88=E6=9C=AC=E4=B8=8B=E7=9A=84=E5=B0=8F=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E6=9B=B4=E6=96=B0=20#1841?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/service/image/ImageReleaseService.kt | 11 +++++++---- .../atom/impl/MarketAtomCommonServiceImpl.kt | 1 + .../store/service/common/StoreCommonService.kt | 1 + .../common/impl/StoreCommonServiceImpl.kt | 18 ++++++++++++------ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/backend/ci/core/store/biz-store-image/src/main/kotlin/com/tencent/devops/store/service/image/ImageReleaseService.kt b/src/backend/ci/core/store/biz-store-image/src/main/kotlin/com/tencent/devops/store/service/image/ImageReleaseService.kt index 3a59bb76815..0465803a8a6 100644 --- a/src/backend/ci/core/store/biz-store-image/src/main/kotlin/com/tencent/devops/store/service/image/ImageReleaseService.kt +++ b/src/backend/ci/core/store/biz-store-image/src/main/kotlin/com/tencent/devops/store/service/image/ImageReleaseService.kt @@ -369,10 +369,13 @@ abstract class ImageReleaseService { val requireVersionList = if (cancelFlag && releaseType == ReleaseTypeEnum.CANCEL_RE_RELEASE) { listOf(dbVersion) - } else storeCommonService.getRequireVersion( - dbVersion, - releaseType - ) + } else { + storeCommonService.getRequireVersion( + reqVersion = version, + dbVersion = dbVersion, + releaseType = releaseType + ) + } if (!requireVersionList.contains(version)) { return MessageCodeUtil.generateResponseDataObject( StoreMessageCode.USER_IMAGE_VERSION_IS_INVALID, diff --git a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/atom/impl/MarketAtomCommonServiceImpl.kt b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/atom/impl/MarketAtomCommonServiceImpl.kt index 4f3b5181b2c..1ab210fd586 100644 --- a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/atom/impl/MarketAtomCommonServiceImpl.kt +++ b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/atom/impl/MarketAtomCommonServiceImpl.kt @@ -141,6 +141,7 @@ class MarketAtomCommonServiceImpl : MarketAtomCommonService { if (cancelFlag && releaseType == ReleaseTypeEnum.CANCEL_RE_RELEASE) { listOf(dbVersion) } else storeCommonService.getRequireVersion( + reqVersion = version, dbVersion = dbVersion, releaseType = requireReleaseType ) diff --git a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/common/StoreCommonService.kt b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/common/StoreCommonService.kt index ace64146788..3f05a94336b 100644 --- a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/common/StoreCommonService.kt +++ b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/common/StoreCommonService.kt @@ -51,6 +51,7 @@ interface StoreCommonService { * 获取正确的升级版本号 */ fun getRequireVersion( + reqVersion: String, dbVersion: String, releaseType: ReleaseTypeEnum ): List diff --git a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/common/impl/StoreCommonServiceImpl.kt b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/common/impl/StoreCommonServiceImpl.kt index 43fed39c62f..9e2ef1e437a 100644 --- a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/common/impl/StoreCommonServiceImpl.kt +++ b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/common/impl/StoreCommonServiceImpl.kt @@ -109,14 +109,19 @@ class StoreCommonServiceImpl @Autowired constructor( * 获取正确的升级版本号 */ override fun getRequireVersion( + reqVersion: String, dbVersion: String, releaseType: ReleaseTypeEnum ): List { var requireVersionList = listOf(INIT_VERSION) - val dbVersionParts = dbVersion.split(".") - val firstVersionPart = dbVersionParts[0] - val secondVersionPart = dbVersionParts[1] - val thirdVersionPart = dbVersionParts[2] + if (dbVersion.isBlank()) { + return requireVersionList + } + val version = if (releaseType != ReleaseTypeEnum.HIS_VERSION_UPGRADE) dbVersion else reqVersion + val versionParts = version.split(".") + val firstVersionPart = versionParts[0] + val secondVersionPart = versionParts[1] + val thirdVersionPart = versionParts[2] when (releaseType) { ReleaseTypeEnum.INCOMPATIBILITY_UPGRADE -> { requireVersionList = listOf("${firstVersionPart.toInt() + 1}.0.0") @@ -131,9 +136,10 @@ class StoreCommonServiceImpl @Autowired constructor( requireVersionList = listOf(dbVersion) } ReleaseTypeEnum.HIS_VERSION_UPGRADE -> { + val dbVersionParts = dbVersion.split(".") requireVersionList = listOf( - "$firstVersionPart.${secondVersionPart.toInt() + 1}.0", - "$firstVersionPart.$secondVersionPart.${thirdVersionPart.toInt() + 1}" + "${dbVersionParts[0]}.${secondVersionPart.toInt() + 1}.0", + "${dbVersionParts[0]}.$secondVersionPart.${thirdVersionPart.toInt() + 1}" ) } else -> {