Skip to content

Commit

Permalink
pref:研发商店通用化接口封装优化 TencentBlueKing#11049
Browse files Browse the repository at this point in the history
  • Loading branch information
carlyin0801 committed Nov 21, 2024
1 parent 9eb536a commit 93f4c42
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,16 @@ interface UserStoreReleaseResource {
@PathParam("storeId")
storeId: String
): Result<Boolean>

@Operation(summary = "返回上一步")
@PUT
@Path("/components/{storeId}/step/back")
fun back(
@Parameter(description = "userId", required = true)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "组件Id", required = true)
@PathParam("storeId")
storeId: String
): Result<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,8 @@ class UserStoreReleaseResourceImpl @Autowired constructor(
override fun rebuild(userId: String, storeId: String): Result<Boolean> {
return Result(storeReleaseService.rebuild(userId, storeId))
}

override fun back(userId: String, storeId: String): Result<Boolean> {
return Result(storeReleaseService.back(userId, storeId))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,15 @@ interface StoreReleaseService {
userId: String,
storeId: String
): Boolean

/**
* 返回上一步
* @param userId userId
* @param storeId 组件ID
* @return 布尔值
*/
fun back(
userId: String,
storeId: String
): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,33 @@ class StoreReleaseServiceImpl @Autowired constructor(
return true
}

override fun back(userId: String, storeId: String): Boolean {
val record = storeBaseQueryDao.getComponentById(dslContext, storeId)
?: throw ErrorCodeException(errorCode = CommonMessageCode.PARAMETER_IS_INVALID, params = arrayOf(storeId))
val recordStatus = StoreStatusEnum.valueOf(record.status)
when (recordStatus) {
StoreStatusEnum.TESTING -> {
// 测试中状态的上一步需要进行重新构建
rebuild(userId, storeId)
}

StoreStatusEnum.EDITING -> {
// 把组件状态置为上一步的状态
storeBaseManageDao.updateStoreBaseInfo(
dslContext = dslContext, updateStoreBaseDataPO = UpdateStoreBaseDataPO(
id = storeId, status = StoreStatusEnum.TESTING, modifier = userId
)
)
}

else -> {
// 其它状态不允许回退至上一步
throw ErrorCodeException(errorCode = StoreMessageCode.STORE_RELEASE_STEPS_ERROR)
}
}
return true
}

private fun offlineComponentByVersion(
storeType: StoreTypeEnum,
storeCode: String,
Expand Down Expand Up @@ -620,9 +647,9 @@ class StoreReleaseServiceImpl @Autowired constructor(
)?.fieldValue
val testingValidPreviousStatuses = if (repositoryHashId.isNullOrBlank()) {
// 传包方式可以进入测试中的状态是提交中
listOf(StoreStatusEnum.COMMITTING)
listOf(StoreStatusEnum.COMMITTING, StoreStatusEnum.EDITING)
} else {
listOf(StoreStatusEnum.BUILDING, StoreStatusEnum.CHECKING)
listOf(StoreStatusEnum.BUILDING, StoreStatusEnum.CHECKING, StoreStatusEnum.EDITING)
}
val releasedValidPreviousStatuses = if (isNormalUpgrade == true) {
// 普通升级可以由测试中的状态直接发布
Expand Down

0 comments on commit 93f4c42

Please sign in to comment.