Skip to content

Commit

Permalink
Merge pull request #943 from wangyu096/feature/biz_set
Browse files Browse the repository at this point in the history
feature: 业务集改造-问题修复、代码重构 #728
  • Loading branch information
jsonwan authored May 19, 2022
2 parents 0fc6c4e + 909585a commit 8afda3b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -161,9 +162,15 @@ public Response<PageDataWithAvailableIdList<AppVO, Long>> listAppWithFavor(Strin
if (appResourceScope.getAppId() != null) {
return appResourceScope.getAppId();
}
return appScopeMappingService.getAppIdByScope(
appResourceScope.getType().getValue(), appResourceScope.getId());
}).collect(Collectors.toList());
try {
return appScopeMappingService.getAppIdByScope(
appResourceScope.getType().getValue(), appResourceScope.getId());
} catch (NotFoundException e) {
log.warn("Invalid scope", e);
// 如果业务不存在,那么忽略
return null;
}
}).filter(Objects::nonNull).collect(Collectors.toList());
// 所有可用的AppId
List<Long> availableAppIds = new ArrayList<>();
if (appResourceScopeResult.getAny()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ public ApplicationDTO getAppByScope(ResourceScope resourceScope) {
if (application != null) {
applicationCache.addOrUpdateApp(application);
} else {
throw new NotFoundException(ErrorCode.APP_NOT_EXIST);
log.info("Get app by scope, app not exist in db or cache! resourceScope: {}", resourceScope);
throw new NotFoundException("App not found, resourceScope:" + resourceScope, ErrorCode.APP_NOT_EXIST);
}
}
return application;
Expand Down Expand Up @@ -168,14 +169,16 @@ public List<Long> getBizSetAppIdsForBiz(Long appId) {
allAppTypeGroupMap.get(AppTypeEnum.NORMAL) : new ArrayList<ApplicationDTO>();

//普通业务按部门分组
Map<Long, List<ApplicationDTO>> normalAppGroupMap = normalAppList.stream().filter(normalApp -> normalApp.getOperateDeptId() != null).collect(
Map<Long, List<ApplicationDTO>> normalAppGroupMap =
normalAppList.stream().filter(normalApp -> normalApp.getOperateDeptId() != null).collect(
Collectors.groupingBy(ApplicationDTO::getOperateDeptId));

//查找包含当前业务的业务集
List<ApplicationDTO> appSetList = allAppTypeGroupMap.get(AppTypeEnum.APP_SET);
if (appSetList != null && !appSetList.isEmpty()) {
appSetList.stream().forEach(appSet -> {
List<Long> subAppIds = appSet.getSubBizIds() == null ? new ArrayList<Long>() : appSet.getSubBizIds();
List<Long> subAppIds = appSet.getSubBizIds() == null ? new ArrayList<Long>() :
appSet.getSubBizIds();
Long optDeptId = appSet.getOperateDeptId();
if (optDeptId != null && normalAppGroupMap.get(optDeptId) != null) {
List<Long> normalAppIdList =
Expand Down

0 comments on commit 8afda3b

Please sign in to comment.