refactor(批量聚合项目): 批量聚合项目时不直接抛出异常,通过日志记录警告信息,防止批量聚合项目时已添加项目导致批量聚合失败

This commit is contained in:
欧涛 2026-04-20 09:15:15 +08:00
parent 354c10f841
commit 2897c163f3
2 changed files with 7 additions and 5 deletions

View File

@ -100,7 +100,7 @@ public class ZoneProjectController extends BaseController {
@PostMapping
@ApiOperation("批量新增项目聚合")
public AjaxResult add(@RequestBody @Validated List<ZoneProjectInputVo> zoneProjectInputVoList) {
return toAjax(zoneProjectService.insertBatchZoneProject(zoneProjectInputVoList));
return success(zoneProjectService.insertBatchZoneProject(zoneProjectInputVoList));
}
/**

View File

@ -569,7 +569,7 @@ public class ZoneProjectServiceImpl implements IZoneProjectService {
JSONObject result = gitLinkRequestHelper.doGet(
ZoneGitLinkRequestUrl.PROJECTS(gitLinkProjectSearchVo.genQueryString())
);
return execGitlinkProjectsSearch(zoneId, result,ZoneConstants.GITLINK_RESPONSE_TOTAL_COUNT_KEY);
return execGitlinkProjectsSearch(zoneId, result, ZoneConstants.GITLINK_RESPONSE_TOTAL_COUNT_KEY);
}
@Override
@ -583,7 +583,9 @@ public class ZoneProjectServiceImpl implements IZoneProjectService {
ZoneProject zoneProject = zoneProjectMapper
.selectZoneProjectByGitLinkProjectIdAndZoneId(gitlinkProjectId, zoneId);
if (zoneProject != null) {
throw new ServiceException("该GitLink项目已存在于专区中不可重复添加(专区Id[" + zoneId + "],GitLink项目Id[" + gitlinkProjectId + "])");
// throw new ServiceException("该GitLink项目已存在于专区中不可重复添加(专区Id[" + zoneId + "],GitLink项目Id[" + gitlinkProjectId + "])");
logger.warn("该GitLink项目已存在于专区中不可重复添加(专区Id[{}],GitLink项目Id[{}])", zoneId, gitlinkProjectId);
break;
}
success += insertZoneProject(zoneProjectInputVo);
}
@ -766,10 +768,10 @@ public class ZoneProjectServiceImpl implements IZoneProjectService {
JSONObject result = gitLinkRequestHelper.doGet(
ZoneGitLinkRequestUrl.MY_OWNER_PROJECTS(SecurityUtils.getUsername(), gitLinkProjectSearchVo.myProjectsQueryString())
);
return execGitlinkProjectsSearch(zoneId, result,ZoneConstants.GITLINK_RESPONSE_COUNT_KEY);
return execGitlinkProjectsSearch(zoneId, result, ZoneConstants.GITLINK_RESPONSE_COUNT_KEY);
}
private GenericsTableDataInfo<JSONObject> execGitlinkProjectsSearch(Long zoneId, JSONObject result,String totalKey) {
private GenericsTableDataInfo<JSONObject> execGitlinkProjectsSearch(Long zoneId, JSONObject result, String totalKey) {
List<JSONObject> list = result.getList(ZoneConstants.GITLINK_RESPONSE_PROJECTS_KEY, JSONObject.class);
if (list == null) {
throw new ServiceException("Gitlink项目列表获取失败");