From c574324c4c7a221e0ae227cd551abf6f10f53ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?yongyiduan=28=E6=AE=B5=E6=B0=B8=E5=84=84=29?= Date: Wed, 17 Jan 2024 11:54:04 +0800 Subject: [PATCH 1/4] =?UTF-8?q?[stream]=20=E9=A1=B9=E7=9B=AE=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=85=B3=E8=81=94=E5=88=B0=E8=BF=90=E8=90=A5=E4=BA=A7?= =?UTF-8?q?=E5=93=81=20#9948?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/user/UserStreamProjectResource.kt | 37 ++++++++++ .../user/UserStreamProjectResourceImpl.kt | 67 ++++++++++++++++++- 2 files changed, 103 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/user/UserStreamProjectResource.kt b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/user/UserStreamProjectResource.kt index 3e884582833..b94b618f419 100644 --- a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/user/UserStreamProjectResource.kt +++ b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/user/UserStreamProjectResource.kt @@ -27,10 +27,14 @@ package com.tencent.devops.stream.api.user +import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_ACCESS_TOKEN +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 @@ -41,6 +45,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 @@ -91,4 +96,36 @@ interface UserStreamProjectResource { @QueryParam("pageSize") size: Long? ): Result> + + @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 + + @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 } diff --git a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/user/UserStreamProjectResourceImpl.kt b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/user/UserStreamProjectResourceImpl.kt index ba5d50f65e8..568074e8346 100644 --- a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/user/UserStreamProjectResourceImpl.kt +++ b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/user/UserStreamProjectResourceImpl.kt @@ -27,10 +27,18 @@ 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.ProjectUpdateInfo +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 @@ -40,7 +48,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, @@ -67,6 +77,61 @@ class UserStreamProjectResourceImpl @Autowired constructor( return Result(streamProjectService.getUserProjectHistory(userId, size = fixPageSize) ?: emptyList()) } + override fun getProjectInfo(userId: String, projectId: String): Result { + 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 { + permissionService.checkStreamPermission( + userId = userId, + projectId = projectId, + permission = AuthPermission.EDIT + ) + val projectInfo = client.get(ServiceProjectResource::class).get(projectId).data + ?: throw OperationException("project $projectId not found") + val updateProject = with(organization) { + ProjectUpdateInfo( + projectName = projectInfo.projectName, + projectType = projectInfo.projectType ?: 0, + bgId = bgId ?: 0, + bgName = bgName ?: "", + businessLineId = businessLineId, + businessLineName = businessLineName, + centerId = centerId ?: 0, + centerName = centerName ?: "", + deptId = deptId ?: 0, + deptName = deptName ?: "", + description = projectInfo.description ?: "", + englishName = projectInfo.englishName, + ccAppId = projectInfo.ccAppId, + ccAppName = projectInfo.ccAppName, + kind = projectInfo.kind, + secrecy = projectInfo.secrecy ?: false, + properties = projectInfo.properties, + subjectScopes = projectInfo.subjectScopes, + logoAddress = projectInfo.logoAddr, + authSecrecy = projectInfo.authSecrecy, + productId = productId, + productName = productName + ) + } + return Result(client.get(ServiceProjectResource::class).update(userId, projectId, updateProject).data!!) + } + private val maxPageSize = 10L private val defaultPageSize = 4L } From ffcdd9566b83f0d0124f61011e43b2e397b46248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?yongyiduan=28=E6=AE=B5=E6=B0=B8=E5=84=84=29?= Date: Wed, 17 Jan 2024 14:47:35 +0800 Subject: [PATCH 2/4] =?UTF-8?q?[stream]=20=E9=A1=B9=E7=9B=AE=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=85=B3=E8=81=94=E5=88=B0=E8=BF=90=E8=90=A5=E4=BA=A7?= =?UTF-8?q?=E5=93=81=20#9948?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stream/resources/user/UserStreamProjectResourceImpl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/user/UserStreamProjectResourceImpl.kt b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/user/UserStreamProjectResourceImpl.kt index 568074e8346..dcd6336e4d6 100644 --- a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/user/UserStreamProjectResourceImpl.kt +++ b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/user/UserStreamProjectResourceImpl.kt @@ -122,7 +122,7 @@ class UserStreamProjectResourceImpl @Autowired constructor( kind = projectInfo.kind, secrecy = projectInfo.secrecy ?: false, properties = projectInfo.properties, - subjectScopes = projectInfo.subjectScopes, + subjectScopes = projectInfo.subjectScopes ?: emptyList(), logoAddress = projectInfo.logoAddr, authSecrecy = projectInfo.authSecrecy, productId = productId, From a637a890eef35f5f6d548ac5bc02520e1ad66b9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?yongyiduan=28=E6=AE=B5=E6=B0=B8=E5=84=84=29?= Date: Wed, 17 Jan 2024 17:19:34 +0800 Subject: [PATCH 3/4] =?UTF-8?q?[stream]=20=E9=A1=B9=E7=9B=AE=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=85=B3=E8=81=94=E5=88=B0=E8=BF=90=E8=90=A5=E4=BA=A7?= =?UTF-8?q?=E5=93=81=20#9948?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ServiceProjectResource.kt | 25 ++++++++++++++ .../resources/ServiceProjectResourceImpl.kt | 23 +++++++++++++ .../devops/project/service/ProjectService.kt | 7 +++- .../service/impl/AbsProjectServiceImpl.kt | 12 +++++++ .../user/UserStreamProjectResourceImpl.kt | 33 ++----------------- 5 files changed, 69 insertions(+), 31 deletions(-) diff --git a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectResource.kt b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectResource.kt index 86adf4b55f8..952b76f45c5 100644 --- a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectResource.kt +++ b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectResource.kt @@ -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 @@ -333,4 +334,28 @@ interface ServiceProjectResource { @ApiParam(value = "ke", required = true) subjectScopes: List ): Result + + @PUT + @Path("{projectId}/updateProjectProductId") + @ApiOperation("修改项目关联产品") + fun updateProjectProductId( + @ApiParam(value = "项目code", required = true) + @PathParam("projectId") + projectCode: String, + @ApiParam("产品名称", required = true) + @QueryParam("productName") + productName: String + ): Result + + + @PUT + @Path("{projectId}/updateOrganizationByEnglishName") + @ApiOperation("修改项目组织架构") + fun updateOrganizationByEnglishName( + @ApiParam(value = "项目code", required = true) + @PathParam("projectId") + projectCode: String, + @ApiParam("产品名称", required = true) + projectOrganizationInfo: ProjectOrganizationInfo + ): Result } diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/resources/ServiceProjectResourceImpl.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/resources/ServiceProjectResourceImpl.kt index fc94d7998a6..ccc5f06d566 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/resources/ServiceProjectResourceImpl.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/resources/ServiceProjectResourceImpl.kt @@ -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 @@ -231,4 +232,26 @@ class ServiceProjectResourceImpl @Autowired constructor( ) ) } + + override fun updateProjectProductId( + projectCode: String, + productName: String + ): Result { + projectService.updateProjectProductId( + englishName = projectCode, + productName = productName + ) + return Result(true) + } + + override fun updateOrganizationByEnglishName( + projectCode: String, + projectOrganizationInfo: ProjectOrganizationInfo + ): Result { + projectService.updateOrganizationByEnglishName( + englishName = projectCode, + projectOrganizationInfo = projectOrganizationInfo + ) + return Result(true) + } } diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/ProjectService.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/ProjectService.kt index 987aec072f1..eead4f88a14 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/ProjectService.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/ProjectService.kt @@ -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 { @@ -259,6 +259,11 @@ interface ProjectService { productName: String ) + fun updateOrganizationByEnglishName( + englishName: String, + projectOrganizationInfo: ProjectOrganizationInfo + ) + fun fixProjectOrganization( tProjectRecord: TProjectRecord ): ProjectOrganizationInfo diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/AbsProjectServiceImpl.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/AbsProjectServiceImpl.kt index 15b4aae9a77..13c1a7da8b9 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/AbsProjectServiceImpl.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/AbsProjectServiceImpl.kt @@ -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 @@ -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 diff --git a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/user/UserStreamProjectResourceImpl.kt b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/user/UserStreamProjectResourceImpl.kt index dcd6336e4d6..6ae5a718572 100644 --- a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/user/UserStreamProjectResourceImpl.kt +++ b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/user/UserStreamProjectResourceImpl.kt @@ -35,7 +35,6 @@ 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.ProjectUpdateInfo import com.tencent.devops.project.pojo.ProjectVO import com.tencent.devops.stream.api.user.UserStreamProjectResource import com.tencent.devops.stream.permission.StreamPermissionService @@ -101,35 +100,9 @@ class UserStreamProjectResourceImpl @Autowired constructor( projectId = projectId, permission = AuthPermission.EDIT ) - val projectInfo = client.get(ServiceProjectResource::class).get(projectId).data - ?: throw OperationException("project $projectId not found") - val updateProject = with(organization) { - ProjectUpdateInfo( - projectName = projectInfo.projectName, - projectType = projectInfo.projectType ?: 0, - bgId = bgId ?: 0, - bgName = bgName ?: "", - businessLineId = businessLineId, - businessLineName = businessLineName, - centerId = centerId ?: 0, - centerName = centerName ?: "", - deptId = deptId ?: 0, - deptName = deptName ?: "", - description = projectInfo.description ?: "", - englishName = projectInfo.englishName, - ccAppId = projectInfo.ccAppId, - ccAppName = projectInfo.ccAppName, - kind = projectInfo.kind, - secrecy = projectInfo.secrecy ?: false, - properties = projectInfo.properties, - subjectScopes = projectInfo.subjectScopes ?: emptyList(), - logoAddress = projectInfo.logoAddr, - authSecrecy = projectInfo.authSecrecy, - productId = productId, - productName = productName - ) - } - return Result(client.get(ServiceProjectResource::class).update(userId, projectId, updateProject).data!!) + client.get(ServiceProjectResource::class).updateProjectProductId(projectId, productName) + client.get(ServiceProjectResource::class).updateOrganizationByEnglishName(projectId, organization) + return Result(true) } private val maxPageSize = 10L From 060d98d05ba78fd755e6b7d0a4834084930a17a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?yongyiduan=28=E6=AE=B5=E6=B0=B8=E5=84=84=29?= Date: Wed, 17 Jan 2024 17:27:52 +0800 Subject: [PATCH 4/4] =?UTF-8?q?[stream]=20=E9=A1=B9=E7=9B=AE=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=85=B3=E8=81=94=E5=88=B0=E8=BF=90=E8=90=A5=E4=BA=A7?= =?UTF-8?q?=E5=93=81=20#9948?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tencent/devops/project/api/service/ServiceProjectResource.kt | 1 - .../tencent/devops/stream/api/user/UserStreamProjectResource.kt | 1 - 2 files changed, 2 deletions(-) diff --git a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectResource.kt b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectResource.kt index 952b76f45c5..d0739c26d8e 100644 --- a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectResource.kt +++ b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectResource.kt @@ -347,7 +347,6 @@ interface ServiceProjectResource { productName: String ): Result - @PUT @Path("{projectId}/updateOrganizationByEnglishName") @ApiOperation("修改项目组织架构") diff --git a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/user/UserStreamProjectResource.kt b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/user/UserStreamProjectResource.kt index b94b618f419..a32b5d59b60 100644 --- a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/user/UserStreamProjectResource.kt +++ b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/user/UserStreamProjectResource.kt @@ -27,7 +27,6 @@ package com.tencent.devops.stream.api.user -import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_ACCESS_TOKEN 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