Skip to content

Commit

Permalink
feat: quality新增matchRuleList的app接口 #10610
Browse files Browse the repository at this point in the history
  • Loading branch information
stubenhuang committed Jul 3, 2024
1 parent a7229b5 commit d24485b
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.tencent.devops.quality.api.v2

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.Result
import com.tencent.devops.quality.api.v2.pojo.response.QualityRuleMatchTask
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.Parameter
import io.swagger.v3.oas.annotations.tags.Tag
import javax.ws.rs.Consumes
import javax.ws.rs.GET
import javax.ws.rs.HeaderParam
import javax.ws.rs.Path
import javax.ws.rs.PathParam
import javax.ws.rs.Produces
import javax.ws.rs.QueryParam
import javax.ws.rs.core.MediaType

@Tag(name = "USER_RULE_V2", description = "质量红线-拦截规则v2")
@Path("/app/rules/v2")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
interface AppQualityRuleResource {
@Operation(summary = "匹配拦截规则")
@Path("/{projectId}/matchRuleList")
@GET
fun matchRuleList(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "项目ID", required = true)
@PathParam("projectId")
projectId: String,
@Parameter(description = "流水线ID", required = false, example = "1")
@QueryParam("pipelineId")
pipelineId: String
): Result<List<QualityRuleMatchTask>>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.tencent.devops.quality.resources.v2

import com.tencent.devops.common.api.exception.ParamBlankException
import com.tencent.devops.common.api.pojo.Result
import com.tencent.devops.common.web.RestResource
import com.tencent.devops.quality.api.v2.AppQualityRuleResource
import com.tencent.devops.quality.api.v2.pojo.response.QualityRuleMatchTask
import com.tencent.devops.quality.service.v2.QualityRuleCheckService
import org.springframework.beans.factory.annotation.Autowired

@RestResource
class AppQualityRuleResourceImpl @Autowired constructor(
private val ruleCheckService: QualityRuleCheckService
) : AppQualityRuleResource {
override fun matchRuleList(
userId: String,
projectId: String,
pipelineId: String
): Result<List<QualityRuleMatchTask>> {
checkParam(userId, projectId)
val result = ruleCheckService.userGetMatchRuleList(projectId, pipelineId)
return Result(result)
}

private fun checkParam(userId: String, projectId: String) {
if (userId.isBlank()) {
throw ParamBlankException("Invalid userId")
}
if (projectId.isBlank()) {
throw ParamBlankException("Invalid projectId")
}
}
}

0 comments on commit d24485b

Please sign in to comment.