Commit b586b3b8 authored by renjie's avatar renjie

shop接口bug修改

parent 10cd257b
......@@ -8,8 +8,8 @@ import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.List;
public interface ShopRepository extends MongoRepository<Shop, String> {
Page<Shop> findByShopIdInAndIpRegionLike(List<String> shopIds, String ipRegion, Pageable pageable);
Page<Shop> findByShopIdInAndShopAccountLike(List<String> shopIds, String shopAccount, Pageable pageable);
Page<Shop> findByShopIdInAndShopNameLike(List<String> shopIds, String shopName, Pageable pageable);
Page<Shop> findByShopIdIn(List<String> shopIds, Pageable pageable);
List<Shop> findByShopIdInAndIpRegionLike(List<String> shopIds, String ipRegion);
List<Shop> findByShopIdInAndShopAccountLike(List<String> shopIds, String shopAccount);
List<Shop> findByShopIdInAndShopNameLike(List<String> shopIds, String shopName);
List<Shop> findByShopIdIn(List<String> shopIds);
}
......@@ -250,7 +250,7 @@ public class ShopServiceImpl implements ShopService {
throw new ClientRequestException(AccountErrorCode.NOPERMISSION);
}
Pageable pageable = PageRequest.of(0, 100);
List<Shop> shops = shopRepository.findByShopIdIn(shopIds, pageable).getContent();
List<Shop> shops = shopRepository.findByShopIdIn(shopIds);
if (shops == null || shops.size() < 1)
throw new ClientRequestException(BrowserErrorCode.SHOPNOTEXIST);
List<Account> accounts = accountRepository.findByNameIn(users);
......@@ -296,22 +296,19 @@ public class ShopServiceImpl implements ShopService {
shopIds = userShopRepository.findByUsernameAndGroupId(username, groupId).stream().
map(x -> x.getShopId()).collect(Collectors.toList());
}
logger.error("shopIds.size " + shopIds.size());
Page<Shop> shops;
List<Shop> shops;
if (filterDto != null && StringUtils.isNotBlank(filterDto.getIpRegion()))
shops = shopRepository.findByShopIdInAndIpRegionLike(shopIds, filterDto.getIpRegion(), pageable);
shops = shopRepository.findByShopIdInAndIpRegionLike(shopIds, filterDto.getIpRegion());
else if (filterDto != null && StringUtils.isNotBlank(filterDto.getShopAccount()))
shops = shopRepository.findByShopIdInAndShopAccountLike(shopIds, filterDto.getShopAccount(), pageable);
shops = shopRepository.findByShopIdInAndShopAccountLike(shopIds, filterDto.getShopAccount());
else if (filterDto != null && StringUtils.isNotBlank(filterDto.getShopName()))
shops = shopRepository.findByShopIdInAndShopNameLike(shopIds, filterDto.getShopName(), pageable);
shops = shopRepository.findByShopIdInAndShopNameLike(shopIds, filterDto.getShopName());
else
shops = shopRepository.findByShopIdIn(shopIds, pageable);
if (shops == null || shops.getNumberOfElements() < 1)
shops = shopRepository.findByShopIdIn(shopIds);
if (shops == null || shops.size() < 1)
return new ShopPageResultDto();
List<ShopDto> shopDtos = new ArrayList<>();
logger.error("numberofelem " + shops.getNumberOfElements());
logger.error("totalelements " + shops.getTotalElements());
shops.getContent().stream().forEach(x -> {
shops.stream().forEach(x -> {
IpResource ipResource = ipResourceRepository.findByAddrAndIsDeleted(x.getIp(), false);
if (ipResource == null)
ipResource = new IpResource();
......
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