Commit 9a6088da authored by jim's avatar jim

ip

parent 97cad9d7
...@@ -106,7 +106,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -106,7 +106,7 @@ public class ShopServiceImpl implements ShopService {
//可以优化 //可以优化
account.setShopCount(account.getShopCount() + 1); account.setShopCount(account.getShopCount() + 1);
accountRepository.save(account); accountRepository.save(account);
}catch (Exception e) { } catch (Exception e) {
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE); throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
} }
return id; return id;
...@@ -170,7 +170,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -170,7 +170,7 @@ public class ShopServiceImpl implements ShopService {
account.setShopCount(account.getShopCount() + 1); account.setShopCount(account.getShopCount() + 1);
accountRepository.save(account); accountRepository.save(account);
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.getMessage());
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE); throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
} }
...@@ -197,7 +197,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -197,7 +197,7 @@ public class ShopServiceImpl implements ShopService {
try { try {
shop_old = shop_old.of(shopResultDto); shop_old = shop_old.of(shopResultDto);
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.getMessage());
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE); throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
} }
...@@ -277,8 +277,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -277,8 +277,7 @@ public class ShopServiceImpl implements ShopService {
if (accounts == null || accounts.size() != users.size()) if (accounts == null || accounts.size() != users.size())
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST); throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST);
for (Account ac : accounts) { for (Account ac : accounts) {
if (ac.getParent() == null || !ac.getParent().equals(username)) if (ac.getParent() == null || !ac.getParent().equals(username)) {
{
throw new ClientRequestException(AccountErrorCode.NOPERMISSION); throw new ClientRequestException(AccountErrorCode.NOPERMISSION);
} }
} }
...@@ -336,8 +335,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -336,8 +335,7 @@ public class ShopServiceImpl implements ShopService {
if (ipResource.isSpecialLine()) { if (ipResource.isSpecialLine()) {
SpecialLine specialLine = specialLineRepository.findAll().get(0); SpecialLine specialLine = specialLineRepository.findAll().get(0);
shopResultDto = ShopResultDto.of(shop, group, new IpResourceDto(ipResource, null, false, specialLine)); shopResultDto = ShopResultDto.of(shop, group, new IpResourceDto(ipResource, null, false, specialLine));
} } else
else
shopResultDto = ShopResultDto.of(shop, group, new IpResourceDto(ipResource, null, false)); shopResultDto = ShopResultDto.of(shop, group, new IpResourceDto(ipResource, null, false));
return shopResultDto; return shopResultDto;
} }
...@@ -369,11 +367,10 @@ public class ShopServiceImpl implements ShopService { ...@@ -369,11 +367,10 @@ public class ShopServiceImpl implements ShopService {
.map(x -> x.getShopId()).collect(Collectors.toList()); .map(x -> x.getShopId()).collect(Collectors.toList());
shopIds = ipResourceRepository.findShopIdInList(allIds, false) shopIds = ipResourceRepository.findShopIdInList(allIds, false)
.stream().flatMap((x -> x.getShopIds().stream())).collect(Collectors.toList()); .stream().flatMap((x -> x.getShopIds().stream())).collect(Collectors.toList());
} } else {
else {
List<String> allIds = userShopRepository.findByUsername(username).stream() List<String> allIds = userShopRepository.findByUsername(username).stream()
.map(x -> x.getShopId()).collect(Collectors.toList()); .map(x -> x.getShopId()).collect(Collectors.toList());
for (String id:allIds) { for (String id : allIds) {
IpResource ipResource = ipResourceRepository.findFirstByShopIdsIsAndIsDeleted(id, false); IpResource ipResource = ipResourceRepository.findFirstByShopIdsIsAndIsDeleted(id, false);
if (ipResource == null) { if (ipResource == null) {
shopIds.add(id); shopIds.add(id);
...@@ -389,11 +386,10 @@ public class ShopServiceImpl implements ShopService { ...@@ -389,11 +386,10 @@ public class ShopServiceImpl implements ShopService {
map(x -> x.getShopId()).collect(Collectors.toList()); map(x -> x.getShopId()).collect(Collectors.toList());
shopIds = ipResourceRepository.findShopIdInList(allIds, false) shopIds = ipResourceRepository.findShopIdInList(allIds, false)
.stream().flatMap((x -> x.getShopIds().stream())).collect(Collectors.toList()); .stream().flatMap((x -> x.getShopIds().stream())).collect(Collectors.toList());
} } else {
else {
List<String> allIds = userShopRepository.findByUsernameAndGroupId(username, groupId).stream() List<String> allIds = userShopRepository.findByUsernameAndGroupId(username, groupId).stream()
.map(x -> x.getShopId()).collect(Collectors.toList()); .map(x -> x.getShopId()).collect(Collectors.toList());
for (String id:allIds) { for (String id : allIds) {
IpResource ipResource = ipResourceRepository.findFirstByShopIdsIsAndIsDeleted(id, false); IpResource ipResource = ipResourceRepository.findFirstByShopIdsIsAndIsDeleted(id, false);
if (ipResource == null) if (ipResource == null)
shopIds.add(id); shopIds.add(id);
...@@ -405,8 +401,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -405,8 +401,7 @@ public class ShopServiceImpl implements ShopService {
List<String> filter = ipResourceRepository.findShopIdInListAndRegionLike(shopIds, false, shopFilterDto.getIpRegion()) List<String> filter = ipResourceRepository.findShopIdInListAndRegionLike(shopIds, false, shopFilterDto.getIpRegion())
.stream().flatMap((x -> x.getShopIds().stream())).collect(Collectors.toList()); .stream().flatMap((x -> x.getShopIds().stream())).collect(Collectors.toList());
shops = shopRepository.findByShopIdInOrderByCreateTimeDesc(filter, pageable); shops = shopRepository.findByShopIdInOrderByCreateTimeDesc(filter, pageable);
} } else if (shopFilterDto != null && StringUtils.isNotBlank(shopFilterDto.getShopAccount()))
else if (shopFilterDto != null && StringUtils.isNotBlank(shopFilterDto.getShopAccount()))
shops = shopRepository.findByShopIdInAndShopAccountLikeOrderByCreateTimeDesc(shopIds, shopFilterDto.getShopAccount(), pageable); shops = shopRepository.findByShopIdInAndShopAccountLikeOrderByCreateTimeDesc(shopIds, shopFilterDto.getShopAccount(), pageable);
else if (shopFilterDto != null && StringUtils.isNotBlank(shopFilterDto.getShopName())) else if (shopFilterDto != null && StringUtils.isNotBlank(shopFilterDto.getShopName()))
shops = shopRepository.findByShopIdInAndShopNameLikeOrderByCreateTimeDesc(shopIds, shopFilterDto.getShopName(), pageable); shops = shopRepository.findByShopIdInAndShopNameLikeOrderByCreateTimeDesc(shopIds, shopFilterDto.getShopName(), pageable);
...@@ -464,8 +459,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -464,8 +459,7 @@ public class ShopServiceImpl implements ShopService {
if (ipResource.isSpecialLine()) { if (ipResource.isSpecialLine()) {
SpecialLine specialLine = specialLineRepository.findAll().get(0); SpecialLine specialLine = specialLineRepository.findAll().get(0);
shopResultDto = ShopResultDto.of(x, group1, new IpResourceDto(ipResource, null, false, specialLine)); shopResultDto = ShopResultDto.of(x, group1, new IpResourceDto(ipResource, null, false, specialLine));
} } else
else
shopResultDto = ShopResultDto.of(x, group1, new IpResourceDto(ipResource, null, false)); shopResultDto = ShopResultDto.of(x, group1, new IpResourceDto(ipResource, null, false));
shopResultDtos.add(shopResultDto); shopResultDtos.add(shopResultDto);
}); });
...@@ -489,7 +483,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -489,7 +483,7 @@ public class ShopServiceImpl implements ShopService {
List<String> allShopIds = userShopRepository.findByUsername(username).stream().map(x -> x.getShopId()).collect(Collectors.toList()); List<String> allShopIds = userShopRepository.findByUsername(username).stream().map(x -> x.getShopId()).collect(Collectors.toList());
List<String> unbind = new ArrayList<>(); List<String> unbind = new ArrayList<>();
if (allShopIds != null && allShopIds.size() > 0) { if (allShopIds != null && allShopIds.size() > 0) {
for (String id:allShopIds) { for (String id : allShopIds) {
IpResource ipResource = ipResourceRepository.findFirstByShopIdsIsAndIsDeleted(id, false); IpResource ipResource = ipResourceRepository.findFirstByShopIdsIsAndIsDeleted(id, false);
if (ipResource == null) { if (ipResource == null) {
unbind.add(id); unbind.add(id);
...@@ -529,7 +523,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -529,7 +523,7 @@ public class ShopServiceImpl implements ShopService {
if (shopIds != null && shopIds.size() > 0) { if (shopIds != null && shopIds.size() > 0) {
String maxShopId = null; String maxShopId = null;
int max = 0; int max = 0;
for (String shopId:shopIds) { for (String shopId : shopIds) {
int userCount = userShopRepository.countByShopId(shopId); int userCount = userShopRepository.countByShopId(shopId);
if (userCount > max) { if (userCount > max) {
max = userCount; max = userCount;
......
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