-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
【研发商店】支持展示版本日志 #1761 #11477
base: master
Are you sure you want to change the base?
【研发商店】支持展示版本日志 #1761 #11477
Changes from 8 commits
a35783e
320936e
338184d
eca52ec
473800a
3ce0e76
2514776
c0d64fc
b96f034
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,10 +43,12 @@ import com.tencent.devops.store.pojo.common.media.StoreMediaInfo | |
import com.tencent.devops.store.pojo.common.test.StoreTestItem | ||
import com.tencent.devops.store.pojo.common.version.StoreDeskVersionItem | ||
import com.tencent.devops.store.pojo.common.version.StoreShowVersionInfo | ||
import com.tencent.devops.store.pojo.common.version.StoreVersionLogInfo | ||
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.DefaultValue | ||
import javax.ws.rs.GET | ||
import javax.ws.rs.HeaderParam | ||
import javax.ws.rs.Path | ||
|
@@ -319,4 +321,29 @@ interface UserStoreComponentQueryResource { | |
@BkField(patternStyle = BkStyleEnum.CODE_STYLE) | ||
storeCode: String | ||
): Result<List<StoreMediaInfo>?> | ||
|
||
|
||
|
||
@Operation(summary = "根据组件Code获取组件版本日志") | ||
@GET | ||
@Path("/{storeType}/{storeCode}/getVersionLogs/") | ||
fun getStoreVersionLogs( | ||
@Parameter(description = "userId", required = true) | ||
@HeaderParam(AUTH_HEADER_USER_ID) | ||
userId: String, | ||
@Parameter(description = "组件ID", required = true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 是组件标识,不是ID |
||
@PathParam("storeCode") | ||
storeCode: String, | ||
@Parameter(description = "组件类型", required = true) | ||
@PathParam("storeType") | ||
storeType: StoreTypeEnum, | ||
@Parameter(description = "页码", required = true) | ||
@QueryParam("page") | ||
@DefaultValue("1") | ||
page: Int, | ||
@Parameter(description = "每页数量", required = true) | ||
@QueryParam("pageSize") | ||
@DefaultValue("10") | ||
pageSize: Int | ||
): Result<Page<StoreVersionLogInfo>> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.tencent.devops.store.pojo.common.version | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
@Schema(title = "商店组件-版本日志") | ||
data class StoreVersionLogInfo( | ||
@Schema(description = "版本号") | ||
val version: String?, | ||
@Schema(description = "tag") | ||
val tag: String?, | ||
@Schema(description = "最近更新时间") | ||
val lastUpdateTime: String?, | ||
@Schema(description = "更新日志") | ||
val updateLog: String? | ||
|
||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ import com.tencent.devops.common.api.constant.KEY_VERSION | |
import com.tencent.devops.common.api.enums.FrontendTypeEnum | ||
import com.tencent.devops.model.store.tables.TAtom | ||
import com.tencent.devops.model.store.tables.TAtomEnvInfo | ||
import com.tencent.devops.model.store.tables.TAtomVersionLog | ||
import com.tencent.devops.model.store.tables.TStorePipelineRel | ||
import com.tencent.devops.model.store.tables.TStoreProjectRel | ||
import com.tencent.devops.process.utils.KEY_PIPELINE_ID | ||
|
@@ -44,15 +45,16 @@ import com.tencent.devops.store.pojo.common.KEY_CREATOR | |
import com.tencent.devops.store.pojo.common.KEY_LANGUAGE | ||
import com.tencent.devops.store.pojo.common.KEY_PROJECT_CODE | ||
import com.tencent.devops.store.pojo.common.KEY_STORE_CODE | ||
import com.tencent.devops.store.pojo.common.STORE_CODE | ||
import com.tencent.devops.store.pojo.common.StoreBaseInfo | ||
import com.tencent.devops.store.pojo.common.enums.StoreProjectTypeEnum | ||
import com.tencent.devops.store.pojo.common.enums.StoreTypeEnum | ||
import org.jooq.Condition | ||
import org.jooq.DSLContext | ||
import org.jooq.Record | ||
import org.jooq.Record3 | ||
import org.jooq.Result | ||
import org.springframework.stereotype.Repository | ||
import java.time.LocalDateTime | ||
|
||
@Repository(value = "ATOM_COMMON_DAO") | ||
class AtomCommonDao : AbstractStoreCommonDao() { | ||
|
@@ -200,4 +202,29 @@ class AtomCommonDao : AbstractStoreCommonDao() { | |
dslContext.select(ATOM_CODE).from(this).where(ID.eq(storeId)).fetchOne(0, String::class.java) | ||
} | ||
} | ||
|
||
|
||
override fun getStoreComponentVersionLogs( | ||
dslContext: DSLContext, | ||
storeCode: String, | ||
page: Int?, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 现在确定姚分页,page和pageSize不要考虑可为空的情况 |
||
pageSize: Int? | ||
): Result<Record3<String, String, LocalDateTime>>? { | ||
val atom = TAtom.T_ATOM | ||
val atomVersionLogs = TAtomVersionLog.T_ATOM_VERSION_LOG | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这名称后面不应该加s吧 |
||
val baseStep = dslContext.select(atom.VERSION, atomVersionLogs.CONTENT, atom.UPDATE_TIME) | ||
.from(atom) | ||
.join(atomVersionLogs) | ||
.on(atom.ID.eq(atomVersionLogs.ATOM_ID)) | ||
.where(atom.ATOM_STATUS.eq(AtomStatusEnum.RELEASED.status.toByte()).and(atom.ATOM_CODE.eq(storeCode))) | ||
|
||
if (null != page && null != pageSize) { | ||
baseStep.limit((page - 1) * pageSize, pageSize) | ||
} | ||
|
||
return baseStep.fetch() | ||
|
||
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.tencent.devops.store.common.service | ||
|
||
import com.tencent.devops.common.api.pojo.Page | ||
import com.tencent.devops.common.api.pojo.Result | ||
import com.tencent.devops.common.api.util.DateTimeUtil | ||
import com.tencent.devops.common.service.utils.SpringContextUtil | ||
import com.tencent.devops.store.common.dao.AbstractStoreCommonDao | ||
import com.tencent.devops.store.pojo.common.enums.StoreTypeEnum | ||
import com.tencent.devops.store.pojo.common.version.StoreVersionLogInfo | ||
import org.jooq.Record3 | ||
import java.time.LocalDateTime | ||
|
||
abstract class StoreComponentVersonLogService { | ||
|
||
companion object { | ||
val HAS_TAG = setOf(StoreTypeEnum.ATOM) | ||
} | ||
|
||
abstract fun getStoreComponentVersionLogs( | ||
userId: String, | ||
storeCode: String, | ||
storeType: StoreTypeEnum, | ||
page: Int, | ||
pageSize: Int | ||
): Result<Page<StoreVersionLogInfo>> | ||
|
||
|
||
fun getStoreCommonDao(storeType: String): AbstractStoreCommonDao { | ||
return SpringContextUtil.getBean(AbstractStoreCommonDao::class.java, "${storeType}_COMMON_DAO") | ||
} | ||
|
||
fun createStoreVersionLogInfo( | ||
record: Record3<String, String, LocalDateTime>, | ||
storeType: StoreTypeEnum | ||
): StoreVersionLogInfo { | ||
return StoreVersionLogInfo( | ||
version = record.value1(), | ||
updateLog = record.value2(), | ||
lastUpdateTime = DateTimeUtil.formatDate( | ||
DateTimeUtil.convertLocalDateTimeToDate(record.value3()), | ||
DateTimeUtil.YYYY_MM_DD_HH_MM_SS | ||
), | ||
tag = generateTag(storeType, record.value1(), record.value3()) | ||
) | ||
} | ||
|
||
private fun generateTag(storeType: StoreTypeEnum, version: String, updateTime: LocalDateTime): String { | ||
return if (storeType in HAS_TAG) { | ||
val updateTimeStr = DateTimeUtil.formatDate( | ||
DateTimeUtil.convertLocalDateTimeToDate(updateTime), | ||
DateTimeUtil.YYYY_MM_DD | ||
) | ||
"prod-v${version}-$updateTimeStr" | ||
} else { | ||
" " | ||
} | ||
} | ||
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url定义不符合restful风格:应该是比如:/types/{storeType}/codes/{storeCode}/version/logs/get