Commit e01ba82d authored by jim's avatar jim

null

parent aa9ad17b
...@@ -169,7 +169,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -169,7 +169,7 @@ public class ShopServiceImpl implements ShopService {
ids.add(id); ids.add(id);
} catch (Exception e) { } catch (Exception e) {
logger.error("fail to add shops", e.getMessage()); logger.error("fail to add shops", e);
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE); throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
} }
} }
...@@ -201,7 +201,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -201,7 +201,7 @@ public class ShopServiceImpl implements ShopService {
// 4. 更新店铺信息 // 4. 更新店铺信息
shopRepository.save(shop_old); shopRepository.save(shop_old);
} catch (Exception e) { } catch (Exception e) {
logger.error("fail to update", e.getMessage()); logger.error("fail to update", e);
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE); throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
} }
return shop_old.getShopId(); return shop_old.getShopId();
...@@ -276,7 +276,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -276,7 +276,7 @@ public class ShopServiceImpl implements ShopService {
userShop.setGroupId(groupId); userShop.setGroupId(groupId);
userShopRepository.save(userShop); userShopRepository.save(userShop);
} catch (Exception e) { } catch (Exception e) {
logger.error("fail to unbind", e.getMessage()); logger.error("fail to unbind", e);
throw new ClientRequestException(BrowserErrorCode.UNKNOWN); throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
} }
...@@ -344,7 +344,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -344,7 +344,7 @@ public class ShopServiceImpl implements ShopService {
); );
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("fail to assign", e.getMessage()); logger.error("fail to assign", e);
throw new ClientRequestException(BrowserErrorCode.UNKNOWN); throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
} }
} }
...@@ -404,7 +404,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -404,7 +404,7 @@ public class ShopServiceImpl implements ShopService {
} }
// 4. 根据传入的过滤条件得到 shopIds // 4. 根据传入的过滤条件得到 shopIds
List<String> shopIds = null; List<String> shopIds = new ArrayList<>();
if (shopFilterDto.getBindIp() == 0) { if (shopFilterDto.getBindIp() == 0) {
shopIds = allIds; shopIds = allIds;
...@@ -425,7 +425,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -425,7 +425,7 @@ public class ShopServiceImpl implements ShopService {
} }
} }
amount = amount > 100 ? 100 : amount; amount = Math.min(amount, 100);
Pageable pageable = PageRequest.of(pageNum, amount); Pageable pageable = PageRequest.of(pageNum, amount);
// 5. 根据过滤后的商铺ids 与 其他过滤条件 得到商铺信息并分页 // 5. 根据过滤后的商铺ids 与 其他过滤条件 得到商铺信息并分页
Page<Shop> shops = getShopsByFilter(shopFilterDto, shopIds, pageable); Page<Shop> shops = getShopsByFilter(shopFilterDto, shopIds, pageable);
...@@ -434,7 +434,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -434,7 +434,7 @@ public class ShopServiceImpl implements ShopService {
ShopPageResultDto<ShopResultDto> shopPageResultDto = new ShopPageResultDto<>(); ShopPageResultDto<ShopResultDto> shopPageResultDto = new ShopPageResultDto<>();
if (shops != null && shops.getNumberOfElements() >= 1) { if (shops != null && shops.getNumberOfElements() >= 1) {
List<ShopResultDto> shopResultDtos = new ArrayList<>(); List<ShopResultDto> shopResultDtos = new ArrayList<>();
shops.getContent().stream().forEach( shops.getContent().forEach(
// 设置ip资源状态 并 封装 shopResultDto信息 // 设置ip资源状态 并 封装 shopResultDto信息
x -> { x -> {
IpResource ipResource = ipResourceRepository.findFirstByShopIdsIsAndIsDeleted(x.getShopId(), false); IpResource ipResource = ipResourceRepository.findFirstByShopIdsIsAndIsDeleted(x.getShopId(), false);
...@@ -539,7 +539,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -539,7 +539,7 @@ public class ShopServiceImpl implements ShopService {
// 获取当前登录用户绑定了当前商铺的 所有子用户名 // 获取当前登录用户绑定了当前商铺的 所有子用户名
List<String> shopUsers = userShopRepository.findByShopId(shopId).stream() List<String> shopUsers = userShopRepository.findByShopId(shopId).stream()
.map(x -> x.getUsername()) .map(UserShop::getUsername)
.filter(x -> !x.equals(username)) .filter(x -> !x.equals(username))
.collect(Collectors.toList()); .collect(Collectors.toList());
return shopUsers; return shopUsers;
...@@ -567,7 +567,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -567,7 +567,7 @@ public class ShopServiceImpl implements ShopService {
return shopUsers; return shopUsers;
} }
List<String> users = userShopRepository.findByShopId(maxShopId).stream().map(x -> x.getUsername()).filter(x -> !x.equals(username)).collect(Collectors.toList()); List<String> users = userShopRepository.findByShopId(maxShopId).stream().map(UserShop::getUsername).filter(x -> !x.equals(username)).collect(Collectors.toList());
for (String user : users) { for (String user : users) {
int shopCount = userShopRepository.countByUsernameAndShopIdIn(user, shopIds); int shopCount = userShopRepository.countByUsernameAndShopIdIn(user, shopIds);
if (shopCount < shopIds.size()) { if (shopCount < shopIds.size()) {
...@@ -602,21 +602,19 @@ public class ShopServiceImpl implements ShopService { ...@@ -602,21 +602,19 @@ public class ShopServiceImpl implements ShopService {
} }
} }
Integer result = 0; int result = 0;
Iterator<Map.Entry<Account, List<Account>>> entries = map.entrySet().iterator(); for (Map.Entry<Account, List<Account>> entry : map.entrySet()) {
while (entries.hasNext()) {
Map.Entry<Account, List<Account>> entry = entries.next();
List<Account> children = entry.getValue(); List<Account> children = entry.getValue();
// 查找子类所拥有的店铺 // 查找子类所拥有的店铺
List<Shop> childrenShop = shopRepository.findByOwnerIn(children.stream().map(Account::getName).collect(Collectors.toList())); List<Shop> childrenShop = shopRepository.findByOwnerIn(children.stream().map(Account::getName).collect(Collectors.toList()));
if (childrenShop.size() == 0) { if (childrenShop.size() == 0) {
continue; continue;
} }
List<String> ids = childrenShop.stream().map(x -> x.getShopId()).collect(Collectors.toList()); List<String> ids = childrenShop.stream().map(Shop::getShopId).collect(Collectors.toList());
// 查出来 父账户已有的 usershop信息 // 查出来 父账户已有的 usershop信息
List<UserShop> parentUserShops = userShopRepository.findByUsernameAndShopIdIn(entry.getKey().getName(), ids); List<UserShop> parentUserShops = userShopRepository.findByUsernameAndShopIdIn(entry.getKey().getName(), ids);
List<String> parentShopIds = parentUserShops.stream().map(x -> x.getShopId()).collect(Collectors.toList()); List<String> parentShopIds = parentUserShops.stream().map(UserShop::getShopId).collect(Collectors.toList());
// 剩下的就是 父账户的 usershop 缺失的信息 // 剩下的就是 父账户的 usershop 缺失的信息
ids.removeAll(parentShopIds); ids.removeAll(parentShopIds);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment