Skip to content

Commit

Permalink
feat: 插件管理菜单对应插件列表增加默认公共插件显示 TencentBlueKing#10472
Browse files Browse the repository at this point in the history
  • Loading branch information
yjieliang committed Sep 24, 2024
1 parent 7d3a050 commit c1933fe
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import com.tencent.devops.model.store.tables.TStoreStatisticsTotal
import com.tencent.devops.model.store.tables.records.TAtomRecord
import com.tencent.devops.repository.pojo.AtomRefRepositoryInfo
import com.tencent.devops.repository.pojo.enums.VisibilityLevelEnum
import com.tencent.devops.store.common.utils.VersionUtils
import com.tencent.devops.store.pojo.atom.AtomBaseInfoUpdateRequest
import com.tencent.devops.store.pojo.atom.AtomCreateRequest
import com.tencent.devops.store.pojo.atom.AtomFeatureUpdateRequest
Expand Down Expand Up @@ -87,7 +88,8 @@ import com.tencent.devops.store.pojo.common.KEY_SERVICE_SCOPE
import com.tencent.devops.store.pojo.common.KEY_UPDATE_TIME
import com.tencent.devops.store.pojo.common.enums.StoreProjectTypeEnum
import com.tencent.devops.store.pojo.common.enums.StoreTypeEnum
import com.tencent.devops.store.common.utils.VersionUtils
import java.net.URLDecoder
import java.time.LocalDateTime
import org.jooq.Condition
import org.jooq.DSLContext
import org.jooq.Field
Expand All @@ -98,8 +100,6 @@ import org.jooq.Result
import org.jooq.SelectOnConditionStep
import org.jooq.impl.DSL
import org.springframework.stereotype.Repository
import java.net.URLDecoder
import java.time.LocalDateTime

@Suppress("ALL")
@Repository
Expand Down Expand Up @@ -1403,4 +1403,27 @@ class AtomDao : AtomBaseDao() {
}
}
}

fun batchGetDefaultAtom(dslContext: DSLContext): Result<TAtomRecord> {
return with(TAtom.T_ATOM) {
dslContext.selectFrom(this)
.where(
LATEST_FLAG.eq(true)
.and(DEFAULT_FLAG.eq(true))
)
.fetch()
}
}

fun countDefaultAtom(dslContext: DSLContext): Int {
return with(TAtom.T_ATOM) {
dslContext.selectCount().from(this)
.where(
LATEST_FLAG.eq(true)
.and(DEFAULT_FLAG.eq(true))
)
.fetchOne(0, Int::class.java) ?: 0
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ package com.tencent.devops.store.atom.service.impl

import com.github.benmanes.caffeine.cache.Caffeine
import com.tencent.devops.common.api.constant.CommonMessageCode
import com.tencent.devops.common.api.constant.DEFAULT
import com.tencent.devops.common.api.constant.KEY_BRANCH_TEST_FLAG
import com.tencent.devops.common.api.constant.KEY_DESCRIPTION
import com.tencent.devops.common.api.constant.KEY_DOCSLINK
Expand Down Expand Up @@ -136,6 +137,7 @@ import org.springframework.beans.factory.annotation.Autowired
import java.math.BigDecimal
import java.time.LocalDateTime
import java.util.concurrent.TimeUnit
import org.jooq.Record

/**
* 插件业务逻辑类
Expand Down Expand Up @@ -1055,18 +1057,26 @@ abstract class AtomServiceImpl @Autowired constructor() : AtomService {
): Page<InstalledAtom> {
// 项目下已安装插件记录
val result = mutableListOf<InstalledAtom>()
val count = atomDao.countInstalledAtoms(dslContext, projectCode, classifyCode, name)
val count = if (classifyCode == DEFAULT) {
atomDao.countDefaultAtom(dslContext)
} else {
atomDao.countInstalledAtoms(dslContext, projectCode, classifyCode, name)
}
if (count == 0) {
return Page(page, pageSize, 0, result)
}
val records = atomDao.getInstalledAtoms(
dslContext = dslContext,
projectCode = projectCode,
classifyCode = classifyCode,
name = name,
page = page,
pageSize = pageSize
)
val records = if (classifyCode == DEFAULT) {
atomDao.batchGetDefaultAtom(dslContext)
} else {
atomDao.getInstalledAtoms(
dslContext = dslContext,
projectCode = projectCode,
classifyCode = classifyCode,
name = name,
page = page,
pageSize = pageSize
)
}
val atomCodeList = mutableListOf<String>()
records?.forEach {
atomCodeList.add(it[KEY_ATOM_CODE] as String)
Expand Down
1 change: 1 addition & 0 deletions support-files/i18n/store/message_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ ATOM.classify.scm=SCM
ATOM.classify.security=Security
ATOM.classify.test=Test
ATOM.classify.trigger=Trigger
ATOM.classify.default=Default
ATOM.label.Android=Android
ATOM.label.artifact=Product Upload
ATOM.label.build=Parameterized Construction
Expand Down
1 change: 1 addition & 0 deletions support-files/i18n/store/message_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ ATOM.classify.scm=SCM
ATOM.classify.security=安全
ATOM.classify.test=测试
ATOM.classify.trigger=触发器
ATOM.classify.default=默认
ATOM.label.Andriod=Andriod
ATOM.label.artifact=产出物上传
ATOM.label.build=参数化构建
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ INSERT IGNORE INTO `T_CLASSIFY` (`ID`, `CLASSIFY_CODE`, `CLASSIFY_NAME`, `WEIGHT
('e1bea5430f574f9ea3e0312dc7de9efa', 'trigger', 'trigger', 11, 'system', 'system', '2019-03-05 19:59:42', '2019-03-05 19:59:42', 0);
INSERT IGNORE INTO `T_CLASSIFY` (`ID`, `CLASSIFY_CODE`, `CLASSIFY_NAME`, `WEIGHT`, `CREATOR`, `MODIFIER`, `CREATE_TIME`, `UPDATE_TIME`, `TYPE`) VALUES
('e5de5b6e525e4b0abf6b1d88d2242fe7', 'common', 'other', 1, 'system', 'system', '2019-03-05 19:59:42', '2019-03-06 11:57:43', 0);
INSERT IGNORE INTO `T_CLASSIFY` (`ID`, `CLASSIFY_CODE`, `CLASSIFY_NAME`, `WEIGHT`, `CREATOR`, `MODIFIER`, `CREATE_TIME`, `UPDATE_TIME`, `TYPE`) VALUES
('eab94b17045b48849332e1f891dfce23', 'default', 'default', 1, 'system', 'system', '2019-03-05 19:59:42', '2019-03-06 11:57:43', 0);


INSERT IGNORE INTO `T_CONTAINER` (`ID`, `NAME`, `TYPE`, `OS`, `REQUIRED`, `MAX_QUEUE_MINUTES`, `MAX_RUNNING_MINUTES`, `PROPS`, `CREATOR`, `MODIFIER`, `CREATE_TIME`, `UPDATE_TIME`) VALUES
Expand Down

0 comments on commit c1933fe

Please sign in to comment.