소스 검색

团队判空处理

igl 9 달 전
부모
커밋
c08ae05ad3
1개의 변경된 파일28개의 추가작업 그리고 12개의 파일을 삭제
  1. 28 12
      vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/service/impl/UserInviteServiceImpl.java

+ 28 - 12
vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/service/impl/UserInviteServiceImpl.java

@@ -124,22 +124,30 @@ public class UserInviteServiceImpl extends ServiceImpl<UserInviteMapper, UserInv
         if(param.getType() == null){
             List<Long> userIds = records.stream().filter(e -> e.getSourceType() == 1).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<UserDTO> users = this.userService.listUsers(userIds);
-            map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
-            avatar = users.stream().filter(e -> StringUtils.isNotBlank(e.getAvatar())).collect(Collectors.toMap(UserDTO::getId, UserDTO::getAvatar));
+            if(!CollectionUtils.isEmpty(users)){
+                map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
+                avatar = users.stream().filter(e -> StringUtils.isNotBlank(e.getAvatar())).collect(Collectors.toMap(UserDTO::getId, UserDTO::getAvatar));
+            }
             List<Long> merchantIds = records.stream().filter(e -> e.getSourceType() == 2).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(merchantIds);
-            map.putAll(merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName)));
-            avatar.putAll(merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getLogo)));
+            if(!CollectionUtils.isEmpty(users)){
+                map.putAll(merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName)));
+                avatar.putAll(merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getLogo)));
+            }
         } else if(param.getType() == 1){
             List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<UserDTO> users = this.userService.listUsers(ids);
-            map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
-            avatar = users.stream().filter(e -> StringUtils.isNotBlank(e.getAvatar())).collect(Collectors.toMap(UserDTO::getId, UserDTO::getAvatar));
+            if(!CollectionUtils.isEmpty(users)){
+                map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
+                avatar = users.stream().filter(e -> StringUtils.isNotBlank(e.getAvatar())).collect(Collectors.toMap(UserDTO::getId, UserDTO::getAvatar));
+            }
         } else if(param.getType() == 2){
             List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(ids);
-            map = merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName));
-            avatar = merchants.stream().filter(e -> StringUtils.isNotBlank(e.getLogo())).collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getLogo));
+            if(!CollectionUtils.isEmpty(merchants)) {
+                map = merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName));
+                avatar = merchants.stream().filter(e -> StringUtils.isNotBlank(e.getLogo())).collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getLogo));
+            }
         }
         for(TeamDetailsDTO detailsDTO : records){
             detailsDTO.setName(map.get(detailsDTO.getInviteUserId()));
@@ -190,18 +198,26 @@ public class UserInviteServiceImpl extends ServiceImpl<UserInviteMapper, UserInv
         if(param.getType() == null){
             List<Long> userIds = records.stream().filter(e -> e.getSourceType() == 1).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<UserDTO> users = this.userService.listUsers(userIds);
-            map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
+            if(!CollectionUtils.isEmpty(users)){
+                map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
+            }
             List<Long> merchantIds = records.stream().filter(e -> e.getSourceType() == 2).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(merchantIds);
-            map.putAll(merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName)));
+            if(!CollectionUtils.isEmpty(merchants)){
+                map.putAll(merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName)));
+            }
         } else if(param.getType() == 1){
             List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<UserDTO> users = this.userService.listUsers(ids);
-            map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
+            if(!CollectionUtils.isEmpty(users)){
+                map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
+            }
         } else if(param.getType() == 2){
             List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(ids);
-            map = merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName));
+            if(!CollectionUtils.isEmpty(merchants)){
+                map = merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName));
+            }
         }
         for(TeamDetailsDTO detailsDTO : records){
             detailsDTO.setName(map.get(detailsDTO.getInviteUserId()));