-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: quality新增matchRuleList的app接口 #10610
- Loading branch information
1 parent
a7229b5
commit d24485b
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...y/api-quality/src/main/kotlin/com/tencent/devops/quality/api/v2/AppQualityRuleResource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>> | ||
} |
33 changes: 33 additions & 0 deletions
33
...ity/src/main/kotlin/com/tencent/devops/quality/resources/v2/AppQualityRuleResourceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
} | ||
} |