From 7388abeee86b47a2558686f5cab07bfcf0a4fc61 Mon Sep 17 00:00:00 2001 From: wanjia <553039491@qq.com> Date: Mon, 28 Jul 2025 10:38:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(=E7=A4=BE=E5=8C=BA=E7=89=88=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E7=AE=A1=E7=90=86):#3676=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=A4=BE=E5=8C=BA=E7=96=91=E4=BF=AE=E4=B8=8E=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E9=A1=B9=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PmsIssueTransformationCommentType.java | 24 +++ .../PmsProjectIssuesController.java | 12 ++ .../PmsIssueTransformationCommentRecord.java | 14 ++ .../project/domain/PmsIssuesLinkedCount.java | 13 ++ .../vo/PmsRepoIssueLinkProjectIssuesVo.java | 22 +++ .../pms/project/mapper/ForgeIssuesMapper.java | 14 ++ ...ssueTransformationCommentRecordMapper.java | 16 ++ ...sueTransformationCommentRecordService.java | 9 + .../PmsLinkIssuesAsyncCommentService.java | 178 ++++++++++++++++++ .../service/PmsProjectIssuesService.java | 20 +- ...ransformationCommentRecordServiceImpl.java | 22 +++ .../pms/utils/PmsGitLinkRequestUrl.java | 5 + .../mapper/pms/ForgeIssuesMapper.xml | 49 +++++ .../PmsIssueTransformationCommentRecord.xml | 53 ++++++ 14 files changed, 447 insertions(+), 4 deletions(-) create mode 100644 microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/enums/PmsIssueTransformationCommentType.java create mode 100644 microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/domain/PmsIssueTransformationCommentRecord.java create mode 100644 microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/domain/PmsIssuesLinkedCount.java create mode 100644 microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/domain/vo/PmsRepoIssueLinkProjectIssuesVo.java create mode 100644 microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/mapper/PmsIssueTransformationCommentRecordMapper.java create mode 100644 microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/IPmsIssueTransformationCommentRecordService.java create mode 100644 microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/PmsLinkIssuesAsyncCommentService.java create mode 100644 microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/impl/PmsIssueTransformationCommentRecordServiceImpl.java create mode 100644 microservices-modules/microservices-modules-pms/src/main/resources/mapper/pms/PmsIssueTransformationCommentRecord.xml diff --git a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/enums/PmsIssueTransformationCommentType.java b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/enums/PmsIssueTransformationCommentType.java new file mode 100644 index 000000000..ebd18ca73 --- /dev/null +++ b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/enums/PmsIssueTransformationCommentType.java @@ -0,0 +1,24 @@ +package com.microservices.pms.enums; + +public enum PmsIssueTransformationCommentType { + REQUIREMENT("requirement", "需求阶段"), + DEVELOPMENT("development", "开发阶段"), + TESTING("testing", "测试阶段"); + + private final String key; + private final String name; + + PmsIssueTransformationCommentType(String key, String name) { + this.key = key; + this.name = name; + } + + public String getKey() { + return key; + } + + public String getName() { + return name; + } +} + diff --git a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/controller/PmsProjectIssuesController.java b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/controller/PmsProjectIssuesController.java index b1e0f4129..e50482c69 100644 --- a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/controller/PmsProjectIssuesController.java +++ b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/controller/PmsProjectIssuesController.java @@ -396,4 +396,16 @@ public class PmsProjectIssuesController extends BaseController { boolean result = pmsProjectIssuesService.updateIssueEnterpriseIdentifier(); return success(result); } + + /** + * 添加社区疑修与项目工作项关联 + */ + @RequiresPermissions(value = {"pms:pmsProjectIssues:edit", "pms:pmsProjectIssues:add"}, logical = Logical.OR) + @PostMapping("/repoLink") + @ApiOperation(value = "添加社区疑修与项目工作项关联") + public AjaxResult addRepoIssueLinks(@RequestBody PmsRepoIssueLinkProjectIssuesVo pmsRepoIssueLinkProjectIssuesVo) { + + JSONObject result = pmsProjectIssuesService.addRepoIssueLink(pmsRepoIssueLinkProjectIssuesVo); + return success(result); + } } diff --git a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/domain/PmsIssueTransformationCommentRecord.java b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/domain/PmsIssueTransformationCommentRecord.java new file mode 100644 index 000000000..a6d67d2f9 --- /dev/null +++ b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/domain/PmsIssueTransformationCommentRecord.java @@ -0,0 +1,14 @@ +package com.microservices.pms.project.domain; + +import lombok.Data; + +@Data +public class PmsIssueTransformationCommentRecord { + private Long id; + + private Long gitlinkIssueId; + + private String commentType; + + private Boolean hasComment; +} diff --git a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/domain/PmsIssuesLinkedCount.java b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/domain/PmsIssuesLinkedCount.java new file mode 100644 index 000000000..0c24a511a --- /dev/null +++ b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/domain/PmsIssuesLinkedCount.java @@ -0,0 +1,13 @@ +package com.microservices.pms.project.domain; + +import lombok.Data; + +@Data +public class PmsIssuesLinkedCount { + + private Integer linkedRequirementsCount; + + private Integer linkedTasksCount; + + private Integer linkedBugsCount; +} diff --git a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/domain/vo/PmsRepoIssueLinkProjectIssuesVo.java b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/domain/vo/PmsRepoIssueLinkProjectIssuesVo.java new file mode 100644 index 000000000..9ce284ee0 --- /dev/null +++ b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/domain/vo/PmsRepoIssueLinkProjectIssuesVo.java @@ -0,0 +1,22 @@ +package com.microservices.pms.project.domain.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel("社区疑修关联项目管理工作项对象") +public class PmsRepoIssueLinkProjectIssuesVo { + + @ApiModelProperty("社区仓库Id") + private Long projectRepositoryId; + + @ApiModelProperty("社区工作项id") + private Long issueId; + + @ApiModelProperty("被关联的工作ids") + private Long[] linkIssueIds; + + @ApiModelProperty("项目id") + private Long pmProjectId; +} diff --git a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/mapper/ForgeIssuesMapper.java b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/mapper/ForgeIssuesMapper.java index 863aa9e99..02a2e937a 100644 --- a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/mapper/ForgeIssuesMapper.java +++ b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/mapper/ForgeIssuesMapper.java @@ -2,9 +2,12 @@ package com.microservices.pms.project.mapper; import com.microservices.common.datasource.annotation.Slave; import com.microservices.pms.project.domain.ForgeIssues; +import com.microservices.pms.project.domain.PmsIssuesLinkedCount; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Set; /** * 用户表 数据层 @@ -18,4 +21,15 @@ public interface ForgeIssuesMapper { List getBriefIssues(); int updateForIssues(ForgeIssues forgeIssues); + + // 查询指定linkableId直接关联的所有工作项 + List selectDirectLinkedIssues(@Param("linkableId") Long linkableId, + @Param("linkableType") String linkableType, + @Param("beLinkableType") String beLinkableType); + + // 批量查询多个linkableId关联的所有工作项 + List selectLinkedIssuesByLinkableIds(@Param("linkableIds") List linkableIds, + @Param("beLinkableType") String beLinkableType); + + PmsIssuesLinkedCount getIssuesLinkedCount(@Param("linkIssueIdSet") Set linkIssueIdSet); } diff --git a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/mapper/PmsIssueTransformationCommentRecordMapper.java b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/mapper/PmsIssueTransformationCommentRecordMapper.java new file mode 100644 index 000000000..0c5b341d6 --- /dev/null +++ b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/mapper/PmsIssueTransformationCommentRecordMapper.java @@ -0,0 +1,16 @@ +package com.microservices.pms.project.mapper; + +import com.microservices.pms.project.domain.PmsIssueTransformationCommentRecord; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface PmsIssueTransformationCommentRecordMapper { + boolean insertSelective(PmsIssueTransformationCommentRecord record); + + boolean deleteByGitlinkIssueIdAndCommentType(PmsIssueTransformationCommentRecord record); + + List selectByGitlinkIssueId(@Param("gitlinkIssueId") Long gitlinkIssueId); +} diff --git a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/IPmsIssueTransformationCommentRecordService.java b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/IPmsIssueTransformationCommentRecordService.java new file mode 100644 index 000000000..0a5c372cb --- /dev/null +++ b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/IPmsIssueTransformationCommentRecordService.java @@ -0,0 +1,9 @@ +package com.microservices.pms.project.service; + +import com.microservices.pms.project.domain.PmsIssueTransformationCommentRecord; + +public interface IPmsIssueTransformationCommentRecordService { + + boolean updateByGitlinkIssueId(PmsIssueTransformationCommentRecord record); + +} diff --git a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/PmsLinkIssuesAsyncCommentService.java b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/PmsLinkIssuesAsyncCommentService.java new file mode 100644 index 000000000..9e7b916f3 --- /dev/null +++ b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/PmsLinkIssuesAsyncCommentService.java @@ -0,0 +1,178 @@ +package com.microservices.pms.project.service; + +import com.alibaba.fastjson2.JSONObject; +import com.microservices.common.httpClient.util.GitLinkRequestHelper; +import com.microservices.pms.enums.PmsIssueTransformationCommentType; +import com.microservices.pms.project.domain.PmsIssueTransformationCommentRecord; +import com.microservices.pms.project.domain.PmsIssuesLinkedCount; +import com.microservices.pms.project.domain.SimpleRepository; +import com.microservices.pms.project.domain.vo.PmsRepoIssueLinkProjectIssuesVo; +import com.microservices.pms.project.mapper.ForgeIssuesMapper; +import com.microservices.pms.project.mapper.PmsIssueTransformationCommentRecordMapper; +import com.microservices.pms.utils.PmsGitLinkRequestUrl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +@Service +public class PmsLinkIssuesAsyncCommentService { + + @Autowired + private PmsIssueTransformationCommentRecordMapper pmsIssueTransformationCommentRecordMapper; + @Autowired + private ForgeIssuesMapper forgeIssuesMapper; + + @Lazy + @Autowired + private PmsProjectIssuesService pmsProjectIssuesService; + @Autowired + private GitLinkRequestHelper gitLinkRequestHelper; + + @Autowired + private IPmsIssueTransformationCommentRecordService pmsIssueTransformationCommentRecordService; + + + @Async + public void asyncIssueComment(PmsRepoIssueLinkProjectIssuesVo pmsRepoIssueLinkProjectIssuesVo, Long issueId, Long[] linkIssueIds) { + List records = pmsIssueTransformationCommentRecordMapper.selectByGitlinkIssueId(issueId); + boolean requirementCommented = false; + boolean developmentCommented = false; + boolean testingCommented = false; + + // 检查已存在的评论记录 + for (PmsIssueTransformationCommentRecord record : records) { + if (PmsIssueTransformationCommentType.REQUIREMENT.getKey().equals(record.getCommentType()) && record.getHasComment()) { + requirementCommented = true; + } + if (PmsIssueTransformationCommentType.DEVELOPMENT.getKey().equals(record.getCommentType()) && record.getHasComment()) { + developmentCommented = true; + } + if (PmsIssueTransformationCommentType.TESTING.getKey().equals(record.getCommentType()) && record.getHasComment()) { + testingCommented = true; + } + } + + // 获取关联项数量 + Set linkIssueIdSet = this.getAllLinkedIssueIds(issueId, "Issue", "Issue"); + if (linkIssueIdSet.isEmpty()) { + return; + } + PmsIssuesLinkedCount linkedCounts = forgeIssuesMapper.getIssuesLinkedCount(linkIssueIdSet); + boolean requirementCreated = linkedCounts.getLinkedRequirementsCount() > 0; + boolean developmentCreated = linkedCounts.getLinkedTasksCount() > 0; + boolean testingCreated = linkedCounts.getLinkedBugsCount() > 0; + + // 获取仓库信息 + SimpleRepository simpleRepository = pmsProjectIssuesService.getSimpleRepository(pmsRepoIssueLinkProjectIssuesVo.getProjectRepositoryId()); + + // 处理需求阶段评论 + handleCommentIfNeeded(!requirementCommented, requirementCreated, "本疑修已纳入需求", issueId, simpleRepository); + + // 处理开发阶段评论 + handleCommentIfNeeded(!developmentCommented, developmentCreated, "本疑修正在开发中", issueId, simpleRepository); + + // 处理测试阶段评论 + handleCommentIfNeeded(!testingCommented, testingCreated, "本疑修正在测试中", issueId, simpleRepository); + + // 更新评论状态记录 + updateCommentRecordIfNecessary(requirementCommented, issueId, PmsIssueTransformationCommentType.REQUIREMENT); + updateCommentRecordIfNecessary(developmentCommented, issueId, PmsIssueTransformationCommentType.DEVELOPMENT); + updateCommentRecordIfNecessary(testingCommented, issueId, PmsIssueTransformationCommentType.TESTING); + } + + /** + * 如果需要,则添加评论 + */ + private void handleCommentIfNeeded(boolean shouldComment, boolean isCreated, String note, Long issueId, SimpleRepository simpleRepository) { + if (shouldComment && isCreated) { + JSONObject journalsJson = new JSONObject(); + journalsJson.put("notes", note); + gitLinkRequestHelper.doPost( + PmsGitLinkRequestUrl.ADD_REPO_ISSUE_JOURNAL(issueId, + simpleRepository.getRepoOwner(), + simpleRepository.getRepoIdentifier()), + journalsJson + ); + } + } + + /** + * 如有必要,更新评论记录状态 + */ + private void updateCommentRecordIfNecessary(boolean commented, Long issueId, PmsIssueTransformationCommentType type) { + if (!commented) { + PmsIssueTransformationCommentRecord update = new PmsIssueTransformationCommentRecord(); + update.setGitlinkIssueId(issueId); + update.setCommentType(type.getKey()); + update.setHasComment(true); + pmsIssueTransformationCommentRecordService.updateByGitlinkIssueId(update); + } + } + + /** + * 递归查询所有关联的工作项ID + * @param linkableId 起始工作项ID + * @param linkableType 起始工作项类型 + * @param beLinkableType 关联工作项类型 + * @return 所有关联的工作项ID列表(去重) + */ + public Set getAllLinkedIssueIds(Long linkableId, String linkableType, String beLinkableType) { + Set allLinkedIssueIds = new HashSet<>(); + + // 递归查询所有关联的工作项 + findLinkedIssuesRecursively(Arrays.asList(linkableId), linkableType, beLinkableType, allLinkedIssueIds, 0, 10); + + // 移除起始工作项自身(如果在结果中) + allLinkedIssueIds.remove(linkableId); + + return allLinkedIssueIds; + } + + /** + * 递归查询关联的工作项 + * @param linkableIds 当前层级的工作项ID列表 + * @param linkableType 工作项类型 + * @param beLinkableType 关联工作项类型 + * @param result 结果集合 + * @param currentDepth 当前递归深度 + * @param maxDepth 最大递归深度 + */ + private void findLinkedIssuesRecursively(List linkableIds, + String linkableType, + String beLinkableType, + Set result, + int currentDepth, + int maxDepth) { + // 防止无限递归 + if (currentDepth >= maxDepth || linkableIds == null || linkableIds.isEmpty()) { + return; + } + + // 查询当前层级关联的工作项 + List linkedIssueIds; + // 后续层级查询多个工作项关联的工作项 + linkedIssueIds = forgeIssuesMapper.selectLinkedIssuesByLinkableIds(linkableIds, beLinkableType); + + // 如果没有更多关联的工作项,结束递归 + if (linkedIssueIds == null || linkedIssueIds.isEmpty() || linkedIssueIds.size() == result.size()) { + return; + } + + // 将新发现的关联工作项添加到结果中 + for (Long issueId : linkedIssueIds) { + if (!result.contains(issueId)) { + result.add(issueId); + } + } + + // 递归查询下一层级 + findLinkedIssuesRecursively(linkedIssueIds, linkableType, beLinkableType, result, currentDepth + 1, maxDepth); + } + +} diff --git a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/PmsProjectIssuesService.java b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/PmsProjectIssuesService.java index 912af6012..c3f381ed6 100644 --- a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/PmsProjectIssuesService.java +++ b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/PmsProjectIssuesService.java @@ -12,15 +12,14 @@ import com.microservices.pms.dashboard.domain.vo.MyProjectIssuesSearchVo; import com.microservices.pms.dashboard.domain.vo.MyTodoProjectIssuesSearchVo; import com.microservices.pms.enterprise.domain.PmsEnterprise; import com.microservices.pms.enterprise.service.IPmsEnterpriseService; +import com.microservices.pms.enums.PmsIssueTransformationCommentType; import com.microservices.pms.enums.ProjectIssueStatus; import com.microservices.pms.product.domain.enums.ProductReqStatus; import com.microservices.pms.product.service.IPmsProductRequirementService; -import com.microservices.pms.project.domain.ForgeIssues; -import com.microservices.pms.project.domain.PmsIssueCompletion; -import com.microservices.pms.project.domain.PmsProject; -import com.microservices.pms.project.domain.SimpleRepository; +import com.microservices.pms.project.domain.*; import com.microservices.pms.project.domain.vo.*; import com.microservices.pms.project.mapper.*; +import com.microservices.pms.specialArea.service.SoftwareFactStatisticsServiceImpl; import com.microservices.pms.utils.PmsConstants; import com.microservices.pms.utils.PmsGitLinkRequestUrl; import com.microservices.pms.utils.PmsUtils; @@ -87,6 +86,8 @@ public class PmsProjectIssuesService { private ForgeIssuesMapper forgeIssuesMapper; @Autowired private PmsIssueCompletionMapper pmsIssueCompletionMapper; + @Autowired + private PmsLinkIssuesAsyncCommentService pmsLinkIssuesAsyncCommentService; public JSONObject selectPmsProjectIssuesList(PmsProjectIssuesSearchVo pmsProjectIssuesSearchVo) { @@ -800,4 +801,15 @@ public class PmsProjectIssuesService { } return true; } + + public JSONObject addRepoIssueLink(PmsRepoIssueLinkProjectIssuesVo pmsRepoIssueLinkProjectIssuesVo) { + JSONObject params = new JSONObject(); + Long[] linkIssueIds = pmsRepoIssueLinkProjectIssuesVo.getLinkIssueIds(); + Long pmProjectId = pmsRepoIssueLinkProjectIssuesVo.getPmProjectId(); + Long issueId = pmsRepoIssueLinkProjectIssuesVo.getIssueId(); + params.put("link_ids", linkIssueIds); + JSONObject result = gitLinkRequestHelper.doPost(PmsGitLinkRequestUrl.ADD_ISSUE_LINK(issueId, pmProjectId), params); + pmsLinkIssuesAsyncCommentService.asyncIssueComment(pmsRepoIssueLinkProjectIssuesVo, issueId, linkIssueIds); + return result; + } } diff --git a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/impl/PmsIssueTransformationCommentRecordServiceImpl.java b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/impl/PmsIssueTransformationCommentRecordServiceImpl.java new file mode 100644 index 000000000..3a91f4013 --- /dev/null +++ b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/impl/PmsIssueTransformationCommentRecordServiceImpl.java @@ -0,0 +1,22 @@ +package com.microservices.pms.project.service.impl; + +import com.microservices.pms.project.domain.PmsIssueTransformationCommentRecord; +import com.microservices.pms.project.mapper.PmsIssueTransformationCommentRecordMapper; +import com.microservices.pms.project.service.IPmsIssueTransformationCommentRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +public class PmsIssueTransformationCommentRecordServiceImpl implements IPmsIssueTransformationCommentRecordService { + + @Autowired + private PmsIssueTransformationCommentRecordMapper pmsIssueTransformationCommentRecordMapper; + + @Override + @Transactional + public boolean updateByGitlinkIssueId(PmsIssueTransformationCommentRecord record) { + pmsIssueTransformationCommentRecordMapper.deleteByGitlinkIssueIdAndCommentType(record); + return pmsIssueTransformationCommentRecordMapper.insertSelective(record); + } +} diff --git a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/utils/PmsGitLinkRequestUrl.java b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/utils/PmsGitLinkRequestUrl.java index ec3bee1c9..6960729ef 100644 --- a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/utils/PmsGitLinkRequestUrl.java +++ b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/utils/PmsGitLinkRequestUrl.java @@ -469,4 +469,9 @@ public class PmsGitLinkRequestUrl extends GitLinkRequestUrl { return getGitLinkRequestUrl( buildUri("/api/pm/weekly_issues/personal_issues.json", issueSearch)); } + + public static GitLinkRequestUrl ADD_REPO_ISSUE_JOURNAL(Long issueId, String owner, String repo) { + String path = String.format("/api/v1/%s/%s/issues/%s/journals", owner, repo, issueId); + return getGitLinkRequestUrl(path); + } } diff --git a/microservices-modules/microservices-modules-pms/src/main/resources/mapper/pms/ForgeIssuesMapper.xml b/microservices-modules/microservices-modules-pms/src/main/resources/mapper/pms/ForgeIssuesMapper.xml index 862db6c27..612465315 100644 --- a/microservices-modules/microservices-modules-pms/src/main/resources/mapper/pms/ForgeIssuesMapper.xml +++ b/microservices-modules/microservices-modules-pms/src/main/resources/mapper/pms/ForgeIssuesMapper.xml @@ -58,4 +58,53 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" issues WHERE pm_project_id IS NOT NULL AND (enterprise_identifier IS NULL OR enterprise_identifier = ''); + + + + + + + + + \ No newline at end of file diff --git a/microservices-modules/microservices-modules-pms/src/main/resources/mapper/pms/PmsIssueTransformationCommentRecord.xml b/microservices-modules/microservices-modules-pms/src/main/resources/mapper/pms/PmsIssueTransformationCommentRecord.xml new file mode 100644 index 000000000..9ff2545ac --- /dev/null +++ b/microservices-modules/microservices-modules-pms/src/main/resources/mapper/pms/PmsIssueTransformationCommentRecord.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + DELETE FROM pms_issue_transformation_comment_record + WHERE comment_type = #{commentType} AND gitlink_issue_id = #{gitlinkIssueId} + + + + INSERT INTO pms_issue_transformation_comment_record + + + gitlink_issue_id, + + + comment_type, + + + has_comment, + + + + + #{gitlinkIssueId}, + + + #{commentType}, + + + #{hasComment}, + + + + + + + \ No newline at end of file From ef61378cc48340474da9e0398dcdbd324d1e3746 Mon Sep 17 00:00:00 2001 From: wanjia <553039491@qq.com> Date: Mon, 28 Jul 2025 14:19:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat(=E7=A4=BE=E5=8C=BA=E7=89=88=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E7=AE=A1=E7=90=86):#3676=20=E8=BD=AC=E5=8F=91forge?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=BA=93=E3=80=81=E7=96=91=E4=BF=AE=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PmsForgeApiForwardController.java | 95 +++++++++++++++++++ .../service/PmsForgeApiForwardService.java | 50 ++++++++++ .../pms/utils/PmsGitLinkRequestUrl.java | 25 +++++ 3 files changed, 170 insertions(+) create mode 100644 microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/controller/PmsForgeApiForwardController.java create mode 100644 microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/PmsForgeApiForwardService.java diff --git a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/controller/PmsForgeApiForwardController.java b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/controller/PmsForgeApiForwardController.java new file mode 100644 index 000000000..c5b8a364a --- /dev/null +++ b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/controller/PmsForgeApiForwardController.java @@ -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); + } + +} diff --git a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/PmsForgeApiForwardService.java b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/PmsForgeApiForwardService.java new file mode 100644 index 000000000..53ae52903 --- /dev/null +++ b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/project/service/PmsForgeApiForwardService.java @@ -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)); + } +} diff --git a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/utils/PmsGitLinkRequestUrl.java b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/utils/PmsGitLinkRequestUrl.java index 6960729ef..58c6281f2 100644 --- a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/utils/PmsGitLinkRequestUrl.java +++ b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/utils/PmsGitLinkRequestUrl.java @@ -474,4 +474,29 @@ public class PmsGitLinkRequestUrl extends GitLinkRequestUrl { String path = String.format("/api/v1/%s/%s/issues/%s/journals", owner, repo, issueId); 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); + } }