Skip to content
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

项目支持关联运营产品和根据运营产品搜索 #9636 #9637

Merged
merged 25 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9b48015
--story=114851875 项目支持关联运营产品和根据运营产品搜索
fcfang123 Nov 2, 2023
99b1550
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 2, 2023
df72ab4
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 2, 2023
defadc8
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 2, 2023
96601b0
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 2, 2023
0cd8013
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 3, 2023
80c6c64
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 3, 2023
f227da5
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 3, 2023
7a3c5de
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 3, 2023
f779fdd
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 3, 2023
ce55c6e
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 6, 2023
cb306a6
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 6, 2023
c274a44
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 6, 2023
a949275
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 6, 2023
b6f07a1
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 7, 2023
bdf66cf
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 7, 2023
d200be2
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 7, 2023
734b834
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 8, 2023
191bea5
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 8, 2023
2276307
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 13, 2023
995e84a
Merge branch 'tencent-master' into issue-9636
fcfang123 Nov 13, 2023
9747eee
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 13, 2023
eb0f7a3
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 13, 2023
f6415d0
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 13, 2023
668c8e2
项目支持关联运营产品和根据运营产品搜索 #9636
fcfang123 Nov 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ object AuthI18nConstants {
const val BK_PROJECT_ID = "bkProjectId" // 项目ID
const val BK_PROJECT_DESC = "bkProjectDesc" // 项目描述
const val BK_ORGANIZATION = "bkOrganization" // 所属组织
const val BK_PROJECT_PRODUCT = "bkProjectProduct" // 项目所属运营产品
const val BK_AUTH_SECRECY = "bkAuthSecrecy" // 项目性质
const val BK_SUBJECT_SCOPES = "bkSubjectScopes" // 最大可授权人员范围
const val BK_RESOURCE_TYPE_NAME = "bkResourceTypeName" // 资源类型名称
const val BK_RESOURCE_NAME = "bkResourceName" // 资源名称
const val BK_GROUP_NAME = "bkGroupName" // 用户组名称
const val BK_VALIDITY_PERIOD = "bkValidityPeriod" // 申请期限
const val BK_CREATE_PROJECT_APPROVAL = "bkCreateProjectApproval" // 创建项目{0}审批
const val BK_UPDATE_PROJECT_APPROVAL = "bkUpdateProjectApproval" // 修改项目{0}审批
const val BK_APPLY_TO_JOIN_PROJECT = "bkApplyToJoinProject" // 申请加入项目
const val BK_APPLY_TO_JOIN_GROUP = "bkApplyToJoinGroup" // 申请加入用户组
const val BK_DAY = "bkDay" // days
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.tencent.devops.auth.service

import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import com.tencent.bk.sdk.iam.dto.itsm.ItsmAttrs
import com.tencent.bk.sdk.iam.dto.itsm.ItsmColumn
import com.tencent.bk.sdk.iam.dto.itsm.ItsmContentDTO
Expand Down Expand Up @@ -39,7 +39,7 @@ class ItsmService @Autowired constructor(
private val itsmUrlPrefix: String = ""

fun cancelItsmApplication(itsmCancelApplicationInfo: ItsmCancelApplicationInfo): Boolean {
val itsmResponseDTO = executeHttpPost(
val itsmResponseDTO: ResponseDTO<List<Any>> = executeHttpPost(
urlSuffix = ITSM_APPLICATION_CANCEL_URL_SUFFIX,
body = itsmCancelApplicationInfo
)
Expand All @@ -56,7 +56,7 @@ class ItsmService @Autowired constructor(

fun verifyItsmToken(token: String) {
val param = mapOf("token" to token)
val itsmResponseDTO = executeHttpPost(ITSM_TOKEN_VERITY_URL_SUFFIX, param)
val itsmResponseDTO: ResponseDTO<Map<*, *>> = executeHttpPost(ITSM_TOKEN_VERITY_URL_SUFFIX, param)
val itsmApiResData = itsmResponseDTO.data
logger.info("itsmApiResData:$itsmApiResData")

Expand All @@ -70,11 +70,12 @@ class ItsmService @Autowired constructor(
}

fun getItsmTicketStatus(sn: String): String {
val itsmResponseDTO = executeHttpGet(String.format(ITSM_TICKET_STATUS_URL_SUFFIX, sn))
val itsmResponseDTO: ResponseDTO<Map<*, *>> =
executeHttpGet(String.format(ITSM_TICKET_STATUS_URL_SUFFIX, sn))
return itsmResponseDTO.data?.get("current_status").toString()
}

private fun executeHttpPost(urlSuffix: String, body: Any): ResponseDTO<Map<*, *>> {
private fun <T> executeHttpPost(urlSuffix: String, body: Any): ResponseDTO<T> {
val headerStr = objectMapper.writeValueAsString(mapOf("bk_app_code" to appCode, "bk_app_secret" to appSecret))
.replace("\\s".toRegex(), "")
val requestBody = objectMapper.writeValueAsString(body)
Expand All @@ -89,7 +90,7 @@ class ItsmService @Autowired constructor(
return executeHttpRequest(url, request)
}

private fun executeHttpGet(urlSuffix: String): ResponseDTO<Map<*, *>> {
private fun <T> executeHttpGet(urlSuffix: String): ResponseDTO<T> {
val headerStr = objectMapper.writeValueAsString(mapOf("bk_app_code" to appCode, "bk_app_secret" to appSecret))
.replace("\\s".toRegex(), "")
val url = itsmUrlPrefix + urlSuffix
Expand All @@ -101,14 +102,15 @@ class ItsmService @Autowired constructor(
return executeHttpRequest(url, request)
}

private fun executeHttpRequest(url: String, request: Request): ResponseDTO<Map<*, *>> {
private fun <T> executeHttpRequest(url: String, request: Request): ResponseDTO<T> {
OkhttpUtils.doHttp(request).use {
if (!it.isSuccessful) {
logger.warn("request failed, uri:($url)|response: ($it)")
throw RemoteServiceException("request failed, response:($it)")
}
val responseStr = it.body!!.string()
val responseDTO = objectMapper.readValue<ResponseDTO<Map<*, *>>>(responseStr)
val responseDTO: ResponseDTO<T> =
objectMapper.readValue(responseStr, object : TypeReference<ResponseDTO<T>>() {})
if (responseDTO.code != 0L || !responseDTO.result) {
// 请求错误
logger.warn("request failed, url:($url)|response:($it)")
Expand All @@ -126,8 +128,11 @@ class ItsmService @Autowired constructor(
desc: String,
organization: String,
authSecrecy: Int,
subjectScopes: List<SubjectScopeInfo>
subjectScopes: List<SubjectScopeInfo>,
productName: String,
isCreateProject: Boolean = true
): ItsmContentDTO {
logger.info("build grade manager itsm content:$projectName|$projectId|$organization|$productName")
val itsmColumns = listOf(
ItsmColumn.builder().key("projectName")
.name(I18nUtil.getCodeLanMessage(AuthI18nConstants.BK_PROJECT_NAME)).type(TEXT_TYPE).build(),
Expand All @@ -142,7 +147,9 @@ class ItsmService @Autowired constructor(
ItsmColumn.builder().key("authSecrecy")
.name(I18nUtil.getCodeLanMessage(AuthI18nConstants.BK_AUTH_SECRECY)).type(TEXT_TYPE).build(),
ItsmColumn.builder().key("subjectScopes")
.name(I18nUtil.getCodeLanMessage(AuthI18nConstants.BK_SUBJECT_SCOPES)).type(TEXT_TYPE).build()
.name(I18nUtil.getCodeLanMessage(AuthI18nConstants.BK_SUBJECT_SCOPES)).type(TEXT_TYPE).build(),
ItsmColumn.builder().key("productName")
.name(I18nUtil.getCodeLanMessage(AuthI18nConstants.BK_PROJECT_PRODUCT)).type(TEXT_TYPE).build()
)
val itsmAttrs = ItsmAttrs.builder().column(itsmColumns).build()
val itsmScheme = ItsmScheme.builder().attrs(itsmAttrs).type("table").build()
Expand All @@ -153,13 +160,19 @@ class ItsmService @Autowired constructor(
value["projectId"] = ItsmStyle.builder().value(projectId).build()
value["desc"] = ItsmStyle.builder().value(desc).build()
value["organization"] = ItsmStyle.builder().value(organization).build()
value["productName"] = ItsmStyle.builder().value(productName).build()
value["authSecrecy"] =
ItsmStyle.builder().value(ProjectAuthSecrecyStatus.getStatus(authSecrecy)?.desc ?: "").build()
value["subjectScopes"] = ItsmStyle.builder().value(subjectScopes.joinToString(",") { it.name }).build()
val itsmValue = ItsmValue.builder()
.scheme("content_table")
.label(
I18nUtil.getCodeLanMessage(AuthI18nConstants.BK_CREATE_PROJECT_APPROVAL)
I18nUtil.getCodeLanMessage(
if (isCreateProject)
AuthI18nConstants.BK_CREATE_PROJECT_APPROVAL
else
AuthI18nConstants.BK_UPDATE_PROJECT_APPROVAL
)
)
.value(listOf(value))
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ class PermissionGradeManagerService @Autowired constructor(
type = ALL_MEMBERS,
name = ALL_MEMBERS_NAME
)
)
),
productName = projectApprovalInfo.productName!!
)
val gradeManagerApplicationCreateDTO = GradeManagerApplicationCreateDTO
.builder()
Expand Down Expand Up @@ -309,7 +310,9 @@ class PermissionGradeManagerService @Autowired constructor(
type = ALL_MEMBERS,
name = ALL_MEMBERS_NAME
)
)
),
productName = projectApprovalInfo.productName!!,
isCreateProject = false
)
val gradeManagerDetail = iamV2ManagerService.getGradeManagerDetail(gradeManagerId)
val gradeManagerApplicationUpdateDTO = GradeManagerApplicationUpdateDTO.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,7 @@ data class ProjectInfoResponse(
@ApiModelProperty("流水线数量上限")
val pipelineLimit: Int? = 500,
@ApiModelProperty("项目其他设置")
val properties: ProjectProperties?
val properties: ProjectProperties?,
@ApiModelProperty("产品运营ID")
val productId: Int? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ interface OPProjectResource {
@ApiParam(value = "是否是云研发项目 true:是 false:否", required = true)
@QueryParam(value = "is_remotedev")
remoteDevFlag: Boolean = false,
@ApiParam(value = "运营产品ID", required = true)
@QueryParam(value = "product_id")
productId: Int?,
@Context request: HttpServletRequest
): Result<Map<String, Any?>?>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID
import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID_DEFAULT_VALUE
import com.tencent.devops.common.api.pojo.Pagination
import com.tencent.devops.common.auth.api.AuthPermission
import com.tencent.devops.project.pojo.OperationalProductVO
import com.tencent.devops.project.pojo.ProjectCreateInfo
import com.tencent.devops.project.pojo.ProjectDiffVO
import com.tencent.devops.project.pojo.ProjectLogo
Expand Down Expand Up @@ -330,4 +331,13 @@ interface UserProjectResource {
@PathParam("project_id")
projectId: String
): Result<Boolean>

@GET
@Path("/product/getOperationalProducts")
@ApiOperation("查询运营产品")
fun getOperationalProducts(
@ApiParam("userId", required = true)
@HeaderParam(AUTH_HEADER_DEVOPS_USER_ID)
userId: String
): Result<List<OperationalProductVO>>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.tencent.devops.project.pojo

import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty

@ApiModel("OBS基礎字典数据")
data class ObsBaseDictDTO(
@ApiModelProperty("jsonrpc")
val jsonrpc: String,
@ApiModelProperty("id")
val id: String,
@ApiModelProperty("method")
val method: String,
@ApiModelProperty("params")
val params: Map<String, String>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.tencent.devops.project.pojo

import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty

@ApiModel("OBS运营产品")
data class ObsOperationalProductResponse(
@ApiModelProperty("jsonrpc")
val jsonrpc: String,
@ApiModelProperty("id")
val id: String,
@ApiModelProperty("运营产品")
val result: ObsOperationalProductResult
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.tencent.devops.project.pojo

import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty

@ApiModel("OBS运营产品结果")
data class ObsOperationalProductResult(
@ApiModelProperty("运营产品")
val data: List<OperationalProductVO>
)
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,7 @@ data class OpProjectUpdateInfoRequest(
@ApiModelProperty(value = "流水线数量上限", required = false)
val pipelineLimit: Int? = 500,
@ApiModelProperty("项目相关配置")
val properties: ProjectProperties? = null
val properties: ProjectProperties? = null,
@ApiModelProperty("运营产品id")
val productId: Int? = null
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.tencent.devops.project.pojo

import com.fasterxml.jackson.annotation.JsonProperty
import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty

@ApiModel("运营产品")
data class OperationalProductVO(
@ApiModelProperty("产品ID")
@JsonProperty(value = "ProductId", required = true)
val productId: Int,
@ApiModelProperty("产品ID")
@JsonProperty(value = "ProductName", required = true)
val productName: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -33,51 +33,38 @@ import io.swagger.annotations.ApiModelProperty

data class ProjectApprovalInfo(
@ApiModelProperty("项目名称")
// @JsonProperty("project_name")
val projectName: String,
@ApiModelProperty("项目类型")
val approvalStatus: Int?,
@ApiModelProperty("审批时间")
// @JsonProperty("approval_time")
val approvalTime: String?,
@ApiModelProperty("审批人")
val approver: String?,
@ApiModelProperty("创建时间")
// @JsonProperty("created_at")
val createdAt: String?,
@ApiModelProperty("创建人")
val creator: String?,
@ApiModelProperty("事业群ID")
// @JsonProperty("bg_id")
val bgId: String?,
@ApiModelProperty("事业群名字")
// @JsonProperty("bg_name")
val bgName: String?,
@ApiModelProperty("中心ID")
// @JsonProperty("center_id")
val centerId: String?,
@ApiModelProperty("中心名称")
// @JsonProperty("center_name")
val centerName: String?,
@ApiModelProperty("部门ID")
// @JsonProperty("dept_id")
val deptId: String?,
@ApiModelProperty("部门名称")
// @JsonProperty("dept_name")
val deptName: String?,
@ApiModelProperty("描述")
val description: String?,
@ApiModelProperty("英文缩写")
// @JsonProperty("english_name")
val englishName: String,
@ApiModelProperty("logo地址")
// @JsonProperty("logo_addr")
val logoAddr: String?,
@ApiModelProperty("修改人")
// @JsonProperty("updated_at")
val updator: String?,
@ApiModelProperty("修改时间")
// @JsonProperty("updated_at")
val updatedAt: String?,
@ApiModelProperty("项目最大可授权人员范围")
val subjectScopes: List<SubjectScopeInfo>?,
Expand All @@ -86,5 +73,9 @@ data class ProjectApprovalInfo(
@ApiModelProperty("项目提示状态,0-不展示,1-展示创建成功,2-展示编辑成功")
val tipsStatus: Int,
@ApiModelProperty("项目性质")
val projectType: Int?
val projectType: Int?,
@ApiModelProperty("运营产品ID")
val productId: Int? = null,
@ApiModelProperty("运营产品名称")
val productName: String? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,26 @@ import io.swagger.annotations.ApiModelProperty
@ApiModel("项目-新增模型")
data class ProjectCreateInfo(
@ApiModelProperty("项目名称")
// @JsonProperty("project_name")
val projectName: String,
@ApiModelProperty("英文缩写")
// @JsonProperty("english_name")
val englishName: String,
@ApiModelProperty("项目类型")
// @JsonProperty("project_type")
val projectType: Int = 0,
@ApiModelProperty("描述")
val description: String,
@ApiModelProperty("一级部门ID")
// @JsonProperty("bg_id")
val bgId: Long = 0,
@ApiModelProperty("一级部门名字")
// @JsonProperty("bg_name")
val bgName: String = "",
@ApiModelProperty("二级部门ID")
// @JsonProperty("dept_id")
val deptId: Long = 0,
@ApiModelProperty("二级部门名称")
// @JsonProperty("dept_name")
val deptName: String = "",
@ApiModelProperty("三级部门ID")
// @JsonProperty("center_id")
val centerId: Long = 0,
@ApiModelProperty("三级部门名称")
// @JsonProperty("center_name")
val centerName: String = "",
@ApiModelProperty("是否保密")
// @get:JsonProperty("is_secrecy")
var secrecy: Boolean = false,
@ApiModelProperty("kind")
val kind: Int = 0,
Expand All @@ -75,5 +65,9 @@ data class ProjectCreateInfo(
@ApiModelProperty("logo地址")
val logoAddress: String? = null,
@ApiModelProperty("项目性质")
val authSecrecy: Int? = ProjectAuthSecrecyStatus.PUBLIC.value
val authSecrecy: Int? = ProjectAuthSecrecyStatus.PUBLIC.value,
@ApiModelProperty("运营产品ID")
val productId: Int? = null,
@ApiModelProperty("运营产品名称")
val productName: String? = null
)
Loading
Loading