Merge pull request '查看社区疑修与项目工作项关联接口' (#969) from wanjia9506/microservices:dev_issues_transform into master

This commit is contained in:
wanjia9506 2025-07-30 11:01:53 +08:00
commit 9936c21594
3 changed files with 55 additions and 0 deletions

View File

@ -408,4 +408,16 @@ public class PmsProjectIssuesController extends BaseController {
JSONObject result = pmsProjectIssuesService.addRepoIssueLink(pmsRepoIssueLinkProjectIssuesVo);
return success(result);
}
/**
* 查看社区疑修与项目工作项关联
*/
@RequiresPermissions(value = {"pms:pmsProject:show", "pms:pmsProject:showMe"}, logical = Logical.OR)
@PostMapping("/repoLink/{issueId}")
@ApiOperation(value = "查看社区疑修与项目工作项关联")
public AjaxResult getRepoIssueLinkList(@PathVariable Long issueId) {
JSONObject result = pmsProjectIssuesService.getRepoIssueLinkList(issueId);
return success(result);
}
}

View File

@ -812,4 +812,42 @@ public class PmsProjectIssuesService {
pmsLinkIssuesAsyncCommentService.asyncIssueComment(pmsRepoIssueLinkProjectIssuesVo, issueId, linkIssueIds);
return result;
}
public JSONObject getRepoIssueLinkList(Long issueId) {
JSONObject linkedIssueResult = gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_ISSUE_LINK_LIST(issueId));
Map<Long, JSONObject> projectMap = new HashMap<>();
JSONArray issuesArray = linkedIssueResult.getJSONArray("issues");
if (issuesArray != null && !issuesArray.isEmpty()) {
for (int i = 0; i < issuesArray.size(); i++) {
JSONObject issue = issuesArray.getJSONObject(i);
Long projectId = issue.getLong("pm_project_id");
// 获取项目详情
JSONObject projectInfo;
if (!projectMap.containsKey(projectId)) {
PmsProject pmsProject = pmsProjectMapper.selectPmsProjectById(projectId);
projectInfo = new JSONObject();
projectInfo.put("id", projectId);
projectInfo.put("projectName", pmsProject != null ? pmsProject.getProjectName() : "");
projectInfo.put("issues", new JSONArray());
projectMap.put(projectId, projectInfo);
} else {
projectInfo = projectMap.get(projectId);
}
// 将issue添加到对应项目的issues字段中
JSONArray projectIssues = projectInfo.getJSONArray("issues");
projectIssues.add(issue);
}
}
// 构建最终的返回结果
JSONObject result = new JSONObject();
JSONArray projects = new JSONArray();
projects.addAll(projectMap.values());
result.put("projects", projects);
return result;
}
}

View File

@ -515,4 +515,9 @@ public class PmsGitLinkRequestUrl extends GitLinkRequestUrl {
public static GitLinkRequestUrl DELETE_ISSUE_COMMENT(Long issueId, String owner, String repo, Long journalId) {
return getGitLinkRequestUrl(String.format("/api/v1/%s/%s/issues/%s/journals/%s", owner, repo, issueId, journalId));
}
public static GitLinkRequestUrl GET_ISSUE_LINK_LIST(Long issueId) {
String path = String.format("/api/pm/issues/%s/issue_links", issueId);
return getGitLinkRequestUrl(path);
}
}