feat(社区版项目管理):#3676 转发forge代码库、疑修相关接口

This commit is contained in:
wanjia 2025-07-28 14:19:45 +08:00
parent 7388abeee8
commit ef61378cc4
3 changed files with 170 additions and 0 deletions

View File

@ -0,0 +1,95 @@
package com.microservices.pms.project.controller;
import com.alibaba.fastjson2.JSONObject;
import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.pms.project.service.PmsForgeApiForwardService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import static com.microservices.common.core.web.domain.AjaxResult.success;
@RestController
@RequestMapping("/{enterpriseIdentifier}/forge")
@Api(tags = "项目管理-直接转发forge相关接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "enterpriseIdentifier", value = "企业标识", paramType = "path", dataType = "String")
})
public class PmsForgeApiForwardController {
@Autowired
private PmsForgeApiForwardService pmsForgeApiForwardService;
@GetMapping("/projects")
@ApiOperation("代码库列表")
@ApiParam(name = "projectSearchInputVo",
value = "【字段说明】:更多入参参考forge接口文档\n" +
"page:页码默认为1;\n" +
"limit:每页记录数默认为15;\n" +
"sort_by:排序字段如updated_on;\n" +
"sort_direction:排序方向asc升序或desc降序;\n" +
"is_public:是否公开项目true或false;\n" +
"keyword:代码库名称关键字")
public AjaxResult listProjects(@PathVariable String enterpriseIdentifier, JSONObject projectSearchInputVo)
{
JSONObject result = pmsForgeApiForwardService.selectForgeRepositoryList(enterpriseIdentifier, projectSearchInputVo);
return success(result);
}
@GetMapping("{owner}/{repo}/project")
@ApiOperation("代码库详情")
public AjaxResult getProject(@ApiParam(name = "repo", value = "仓库标识") @PathVariable String repo,
@ApiParam(name = "owner", value = "仓库拥有者") @PathVariable String owner) {
JSONObject result = pmsForgeApiForwardService.selectForgeProject(repo, owner);
return success(result);
}
@GetMapping("{owner}/{repo}/issues")
@ApiOperation("疑修列表")
@ApiParam(name = "issueSearch",
value = "【字段说明】:更多入参参考forge接口文档\n" +
"page:页码默认为1;\n" +
"limit:每页记录数默认为15;\n" +
"sort_by:排序字段如updated_on;\n" +
"sort_direction:排序方向asc升序或desc降序;\n" +
"participant_category:参与类型all 全部 aboutme 关于我的 authoredme 我创建的 assignedme 我负责的 atme @我的;\n" +
"category:疑修类型all 全部 opened 开启中 closed 已关闭;"
)
public AjaxResult listIssues(@ApiParam(name = "repo", value = "仓库标识") @PathVariable String repo,
@ApiParam(name = "owner", value = "仓库拥有者") @PathVariable String owner,
JSONObject issueSearch) {
JSONObject result = pmsForgeApiForwardService.selectForgeIssueList(issueSearch);
return success(result);
}
@GetMapping("{owner}/{repo}/issues/{issue_id}")
@ApiOperation("疑修详情")
public AjaxResult getIssue(@ApiParam(name = "repo", value = "仓库标识") @PathVariable String repo,
@ApiParam(name = "owner", value = "仓库拥有者") @PathVariable String owner,
@ApiParam(name = "issue_id", value = "疑修id") @PathVariable String issue_id) {
JSONObject result = pmsForgeApiForwardService.selectForgeIssue(repo, owner, issue_id);
return success(result);
}
@PatchMapping("{owner}/{repo}/issues/{issue_id}")
@ApiOperation("更新疑修")
public AjaxResult updateIssue(@ApiParam(name = "repo", value = "仓库标识") @PathVariable String repo,
@ApiParam(name = "owner", value = "仓库拥有者") @PathVariable String owner,
@ApiParam(name = "issue_id", value = "疑修id") @PathVariable String issue_id,
@Validated @RequestBody JSONObject issue) {
JSONObject result = pmsForgeApiForwardService.updateForgeIssue(repo, owner, issue_id, issue);
return success(result);
}
@GetMapping("{owner}/{repo}/{issue_url}")
@ApiOperation("疑修相关枚举")
public AjaxResult getIssueEnum(@ApiParam(name = "repo", value = "仓库标识") @PathVariable String repo,
@ApiParam(name = "owner", value = "仓库拥有者") @PathVariable String owner,
@ApiParam(name = "issue_url", value = "疑修url") @PathVariable String issue_url,
@ApiParam(name = "only_name", value = "是否只返回名称") Boolean only_name) {
JSONObject result = pmsForgeApiForwardService.getIssueRelatedEnum(repo, owner, issue_url, only_name);
return success(result);
}
}

View File

@ -0,0 +1,50 @@
package com.microservices.pms.project.service;
import com.alibaba.fastjson2.JSONObject;
import com.microservices.common.httpClient.util.GitLinkRequestHelper;
import com.microservices.pms.utils.PmsGitLinkRequestUrl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.net.URISyntaxException;
@Service
public class PmsForgeApiForwardService {
@Autowired
private GitLinkRequestHelper gitLinkRequestHelper;
public JSONObject selectForgeRepositoryList(String enterpriseIdentifier, JSONObject projectSearchInputVo) {
try {
return gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_ORGANIZATION_PUBLIC_REPO_LIST(enterpriseIdentifier, projectSearchInputVo));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
public JSONObject selectForgeIssueList(JSONObject issueSearch) {
try {
return gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_ISSUE_LIST(issueSearch));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
public JSONObject selectForgeIssue(String repo, String owner, String issueId) {
return gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_ISSUE_DETAILS(repo, owner, issueId));
}
public JSONObject updateForgeIssue(String repo, String owner, String issueId, JSONObject issue) {
return gitLinkRequestHelper.doPatch(PmsGitLinkRequestUrl.UPDATE_ISSUE(repo, owner, issueId), issue);
}
public JSONObject selectForgeProject(String repo, String owner) {
return gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_PROJECT_DETAILS(repo, owner));
}
public JSONObject getIssueRelatedEnum(String repo, String owner, String issueUrl, Boolean only_name) {
return gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_ISSUE_RELATED_ENUM(repo, owner, issueUrl, only_name));
}
}

View File

@ -474,4 +474,29 @@ public class PmsGitLinkRequestUrl extends GitLinkRequestUrl {
String path = String.format("/api/v1/%s/%s/issues/%s/journals", owner, repo, issueId); String path = String.format("/api/v1/%s/%s/issues/%s/journals", owner, repo, issueId);
return getGitLinkRequestUrl(path); return getGitLinkRequestUrl(path);
} }
public static GitLinkRequestUrl GET_ORGANIZATION_PUBLIC_REPO_LIST(String enterpriseIdentifier, JSONObject projectSearchInputVo) throws URISyntaxException {
String path = String.format("/api/v1/%s/projects.json", enterpriseIdentifier);
return getGitLinkRequestUrl(buildUri(path, projectSearchInputVo));
}
public static GitLinkRequestUrl GET_ISSUE_DETAILS(String repo, String owner, String issueId) {
return getGitLinkRequestUrl(String.format("/api/v1/%s/%s/issues/%s", owner, repo, issueId));
}
public static GitLinkRequestUrl UPDATE_ISSUE(String repo, String owner, String issueId) {
return getGitLinkRequestUrl(String.format("/api/v1/%s/%s/issues/%s", owner, repo, issueId));
}
public static GitLinkRequestUrl GET_PROJECT_DETAILS(String repo, String owner) {
return getGitLinkRequestUrl(String.format("/api/%s/%s/simple.json", owner, repo));
}
public static GitLinkRequestUrl GET_ISSUE_RELATED_ENUM(String repo, String owner, String issueUrl, Boolean onlyName) {
String path = String.format("/api/v1/%s/%s/%s", owner, repo, issueUrl);
if (onlyName != null) {
path = path + "?only_name=" + onlyName;
}
return getGitLinkRequestUrl(path);
}
} }