Skip to content

Commit

Permalink
[stream] 项目支持关联到运营产品 TencentBlueKing#9948
Browse files Browse the repository at this point in the history
  • Loading branch information
yongyiduan committed Jan 17, 2024
1 parent ffcdd95 commit a637a89
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 31 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,28 @@ 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 @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a637a89

Please sign in to comment.