Skip to content

Commit

Permalink
Merge pull request TencentBlueKing#9949 from yongyiduan/issue_9948
Browse files Browse the repository at this point in the history
[stream] 项目支持关联到运营产品 TencentBlueKing#9948
  • Loading branch information
mingshewhe authored Jan 22, 2024
2 parents 45cbcd6 + 060d98d commit 3f5e52b
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import com.tencent.devops.project.pojo.OrgInfo
import com.tencent.devops.project.pojo.ProjectBaseInfo
import com.tencent.devops.project.pojo.ProjectCreateInfo
import com.tencent.devops.project.pojo.ProjectCreateUserInfo
import com.tencent.devops.project.pojo.ProjectOrganizationInfo
import com.tencent.devops.project.pojo.ProjectProperties
import com.tencent.devops.project.pojo.ProjectUpdateInfo
import com.tencent.devops.project.pojo.ProjectVO
Expand Down Expand Up @@ -333,4 +334,27 @@ interface ServiceProjectResource {
@ApiParam(value = "ke", required = true)
subjectScopes: List<SubjectScopeInfo>
): Result<Boolean>

@PUT
@Path("{projectId}/updateProjectProductId")
@ApiOperation("修改项目关联产品")
fun updateProjectProductId(
@ApiParam(value = "项目code", required = true)
@PathParam("projectId")
projectCode: String,
@ApiParam("产品名称", required = true)
@QueryParam("productName")
productName: String
): Result<Boolean>

@PUT
@Path("{projectId}/updateOrganizationByEnglishName")
@ApiOperation("修改项目组织架构")
fun updateOrganizationByEnglishName(
@ApiParam(value = "项目code", required = true)
@PathParam("projectId")
projectCode: String,
@ApiParam("产品名称", required = true)
projectOrganizationInfo: ProjectOrganizationInfo
): Result<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import com.tencent.devops.project.pojo.ProjectBaseInfo
import com.tencent.devops.project.pojo.ProjectCreateExtInfo
import com.tencent.devops.project.pojo.ProjectCreateInfo
import com.tencent.devops.project.pojo.ProjectCreateUserInfo
import com.tencent.devops.project.pojo.ProjectOrganizationInfo
import com.tencent.devops.project.pojo.ProjectProperties
import com.tencent.devops.project.pojo.ProjectUpdateInfo
import com.tencent.devops.project.pojo.ProjectVO
Expand Down Expand Up @@ -231,4 +232,26 @@ class ServiceProjectResourceImpl @Autowired constructor(
)
)
}

override fun updateProjectProductId(
projectCode: String,
productName: String
): Result<Boolean> {
projectService.updateProjectProductId(
englishName = projectCode,
productName = productName
)
return Result(true)
}

override fun updateOrganizationByEnglishName(
projectCode: String,
projectOrganizationInfo: ProjectOrganizationInfo
): Result<Boolean> {
projectService.updateOrganizationByEnglishName(
englishName = projectCode,
projectOrganizationInfo = projectOrganizationInfo
)
return Result(true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ import com.tencent.devops.project.pojo.ProjectWithPermission
import com.tencent.devops.project.pojo.Result
import com.tencent.devops.project.pojo.enums.ProjectChannelCode
import com.tencent.devops.project.pojo.enums.ProjectValidateType
import org.glassfish.jersey.media.multipart.FormDataContentDisposition
import java.io.InputStream
import org.glassfish.jersey.media.multipart.FormDataContentDisposition

@Suppress("ALL")
interface ProjectService {
Expand Down Expand Up @@ -259,6 +259,11 @@ interface ProjectService {
productName: String
)

fun updateOrganizationByEnglishName(
englishName: String,
projectOrganizationInfo: ProjectOrganizationInfo
)

fun fixProjectOrganization(
tProjectRecord: TProjectRecord
): ProjectOrganizationInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import com.tencent.devops.project.pojo.ProjectCreateExtInfo
import com.tencent.devops.project.pojo.ProjectCreateInfo
import com.tencent.devops.project.pojo.ProjectDiffVO
import com.tencent.devops.project.pojo.ProjectLogo
import com.tencent.devops.project.pojo.ProjectOrganizationInfo
import com.tencent.devops.project.pojo.ProjectProperties
import com.tencent.devops.project.pojo.ProjectUpdateCreatorDTO
import com.tencent.devops.project.pojo.ProjectUpdateInfo
Expand Down Expand Up @@ -1277,6 +1278,17 @@ abstract class AbsProjectServiceImpl @Autowired constructor(
)
}

override fun updateOrganizationByEnglishName(
englishName: String,
projectOrganizationInfo: ProjectOrganizationInfo
) {
projectDao.updateOrganizationByEnglishName(
dslContext = dslContext,
englishName = englishName,
projectOrganizationInfo = projectOrganizationInfo
)
}

abstract fun validatePermission(projectCode: String, userId: String, permission: AuthPermission): Boolean

abstract fun getDeptInfo(userId: String): UserDeptDetail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@

package com.tencent.devops.stream.api.user

import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID
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.api.pojo.Result
import com.tencent.devops.project.pojo.ProjectOrganizationInfo
import com.tencent.devops.project.pojo.ProjectVO
import com.tencent.devops.stream.pojo.StreamProjectCIInfo
import com.tencent.devops.stream.pojo.enums.StreamProjectType
import com.tencent.devops.stream.pojo.enums.StreamProjectsOrder
Expand All @@ -41,6 +44,7 @@ import io.swagger.annotations.ApiParam
import javax.ws.rs.Consumes
import javax.ws.rs.GET
import javax.ws.rs.HeaderParam
import javax.ws.rs.PUT
import javax.ws.rs.Path
import javax.ws.rs.PathParam
import javax.ws.rs.Produces
Expand Down Expand Up @@ -91,4 +95,36 @@ interface UserStreamProjectResource {
@QueryParam("pageSize")
size: Long?
): Result<List<StreamProjectCIInfo>>

@ApiOperation("获取项目信息")
@GET
@Path("/{english_name}")
fun getProjectInfo(
@ApiParam("userId", required = true)
@HeaderParam(AUTH_HEADER_DEVOPS_USER_ID)
userId: String,
@ApiParam("项目ID英文名标识", required = true)
@PathParam("english_name")
projectId: String
): Result<ProjectVO>

@ApiOperation("更新项目组织架构和归属")
@PUT
@Path("/{english_name}/organization")
fun updateProjectOrganization(
@ApiParam("userId", required = true)
@HeaderParam(AUTH_HEADER_DEVOPS_USER_ID)
userId: String,
@ApiParam("项目ID英文名标识", required = true)
@PathParam("english_name")
projectId: String,
@ApiParam("产品ID", required = true)
@QueryParam("productId")
productId: Int,
@ApiParam("产品名称", required = true)
@QueryParam("productName")
productName: String,
@ApiParam("项目组织", required = true)
organization: ProjectOrganizationInfo
): Result<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@

package com.tencent.devops.stream.resources.user

import com.tencent.devops.common.api.exception.OperationException
import com.tencent.devops.common.api.pojo.Pagination
import com.tencent.devops.common.api.pojo.Result
import com.tencent.devops.common.auth.api.AuthPermission
import com.tencent.devops.common.client.Client
import com.tencent.devops.common.web.RestResource
import com.tencent.devops.project.api.service.ServiceProjectResource
import com.tencent.devops.project.pojo.ProjectOrganizationInfo
import com.tencent.devops.project.pojo.ProjectVO
import com.tencent.devops.stream.api.user.UserStreamProjectResource
import com.tencent.devops.stream.permission.StreamPermissionService
import com.tencent.devops.stream.pojo.StreamProjectCIInfo
import com.tencent.devops.stream.pojo.enums.StreamProjectType
import com.tencent.devops.stream.pojo.enums.StreamProjectsOrder
Expand All @@ -40,7 +47,9 @@ import org.springframework.beans.factory.annotation.Autowired

@RestResource
class UserStreamProjectResourceImpl @Autowired constructor(
private val streamProjectService: StreamProjectService
private val client: Client,
private val streamProjectService: StreamProjectService,
private val permissionService: StreamPermissionService
) : UserStreamProjectResource {
override fun getProjects(
userId: String,
Expand All @@ -67,6 +76,35 @@ class UserStreamProjectResourceImpl @Autowired constructor(
return Result(streamProjectService.getUserProjectHistory(userId, size = fixPageSize) ?: emptyList())
}

override fun getProjectInfo(userId: String, projectId: String): Result<ProjectVO> {
permissionService.checkStreamPermission(
userId = userId,
projectId = projectId,
permission = AuthPermission.VIEW
)
return Result(
client.get(ServiceProjectResource::class).get(projectId).data
?: throw OperationException("project $projectId not found")
)
}

override fun updateProjectOrganization(
userId: String,
projectId: String,
productId: Int,
productName: String,
organization: ProjectOrganizationInfo
): Result<Boolean> {
permissionService.checkStreamPermission(
userId = userId,
projectId = projectId,
permission = AuthPermission.EDIT
)
client.get(ServiceProjectResource::class).updateProjectProductId(projectId, productName)
client.get(ServiceProjectResource::class).updateOrganizationByEnglishName(projectId, organization)
return Result(true)
}

private val maxPageSize = 10L
private val defaultPageSize = 4L
}

0 comments on commit 3f5e52b

Please sign in to comment.