Skip to content

Commit

Permalink
Merge pull request #9874 from fcfang123/issue-9574
Browse files Browse the repository at this point in the history
feat:【蓝盾】【产品评审会-已评审】支持为单个流水线模板设置权限 #9574
  • Loading branch information
mingshewhe authored Dec 27, 2023
2 parents 10c8cdb + 712ca79 commit 5b46792
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.tencent.devops.common.api.exception.ErrorCodeException
import com.tencent.devops.model.process.tables.TTemplate
import com.tencent.devops.model.process.tables.records.TTemplateRecord
import com.tencent.devops.process.constant.ProcessMessageCode
import com.tencent.devops.process.constant.ProcessMessageCode.FAIL_TO_LIST_TEMPLATE_PARAMS
import com.tencent.devops.process.pojo.template.TemplateType
import com.tencent.devops.store.pojo.common.KEY_CREATE_TIME
import com.tencent.devops.store.pojo.common.KEY_ID
Expand Down Expand Up @@ -447,6 +448,11 @@ class TemplateDao {
limit: Int?,
queryModelFlag: Boolean = true
): Result<out Record>? {
if (projectId == null && templateIdList == null && limit == null)
throw ErrorCodeException(
defaultMessage = "list pipeline templates params error",
errorCode = FAIL_TO_LIST_TEMPLATE_PARAMS
)
val tTemplate = TTemplate.T_TEMPLATE

val conditions = mutableListOf<Condition>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,8 @@ class TemplateFacadeService @Autowired constructor(
storeFlag = storeFlag,
hasManagerPermission = hasManagerPermission,
page = page,
pageSize = pageSize
pageSize = pageSize,
templateIds = null
)
logger.info("get templates and count :$templateWithPermission")
fillResult(
Expand Down Expand Up @@ -790,7 +791,8 @@ class TemplateFacadeService @Autowired constructor(
checkPermission: Boolean = true,
page: Int?,
pageSize: Int?,
includePublicFlag: Boolean? = null
includePublicFlag: Boolean? = null,
templateIds: Collection<String>?
): TemplateWithPermission {
val offset = if (null != page && null != pageSize) (page - 1) * pageSize else null
// 若不开启模板权限或者不检查列表权限的,直接返回列表数据。
Expand All @@ -803,7 +805,8 @@ class TemplateFacadeService @Autowired constructor(
storeFlag = storeFlag,
offset = offset,
pageSize = pageSize,
hasManagerPermission = hasManagerPermission
hasManagerPermission = hasManagerPermission,
templateIds = templateIds
)
} else {
logger.info("get templates with permission :$projectId|$userId|$checkPermission")
Expand Down Expand Up @@ -836,15 +839,16 @@ class TemplateFacadeService @Autowired constructor(
storeFlag: Boolean?,
offset: Int?,
pageSize: Int?,
hasManagerPermission: Boolean?
hasManagerPermission: Boolean?,
templateIds: Collection<String>?
): TemplateWithPermission {
val tTemplate = TTemplate.T_TEMPLATE
val templateRecord = templateDao.listTemplate(
dslContext = dslContext,
projectId = projectId,
includePublicFlag = includePublicFlag,
templateType = templateType,
templateIdList = null,
templateIdList = templateIds,
storeFlag = storeFlag,
offset = offset,
limit = pageSize,
Expand Down Expand Up @@ -1163,7 +1167,8 @@ class TemplateFacadeService @Autowired constructor(
checkPermission = checkPermission,
page = page,
pageSize = pageSize,
includePublicFlag = true
includePublicFlag = true,
templateIds = templateIds
)
val templates = templateWithPermission.templatesWithListPermRecords
val templateCount = templateWithPermission.count
Expand Down

0 comments on commit 5b46792

Please sign in to comment.