Commit f08caa40 authored by renjie's avatar renjie

ip地域中文

parent 0d92b023
...@@ -25,6 +25,8 @@ public class Shop { ...@@ -25,6 +25,8 @@ public class Shop {
private String ipRegion; private String ipRegion;
private String ipRegionCn;
private String ip; private String ip;
private String ipId; private String ipId;
...@@ -95,6 +97,8 @@ public class Shop { ...@@ -95,6 +97,8 @@ public class Shop {
this.setShopCookie(shop.getShopCookie()); this.setShopCookie(shop.getShopCookie());
if (shop.getCreateTime() != 0) if (shop.getCreateTime() != 0)
this.setCreateTime(shop.getCreateTime()); this.setCreateTime(shop.getCreateTime());
if (shop.getIpRegionCn() != null)
this.setIpRegionCn(shop.getIpRegionCn());
return this; return this;
} }
...@@ -209,4 +213,12 @@ public class Shop { ...@@ -209,4 +213,12 @@ public class Shop {
public void setCreateTime(long createTime) { public void setCreateTime(long createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
public String getIpRegionCn() {
return ipRegionCn;
}
public void setIpRegionCn(String ipRegionCn) {
this.ipRegionCn = ipRegionCn;
}
} }
...@@ -20,7 +20,7 @@ public interface IpResourceRepository extends MongoRepository<IpResource, String ...@@ -20,7 +20,7 @@ public interface IpResourceRepository extends MongoRepository<IpResource, String
List<IpResource> findByStatusAndIdInAndIsDeleted(int status, List<String> ipIds, boolean isDeleted); List<IpResource> findByStatusAndIdInAndIsDeleted(int status, List<String> ipIds, boolean isDeleted);
Page<IpResource> findByAddrLikeAndIdInAndIsDeletedOrderByPurchasedTimeDesc(String addr, List<String> ipIds, boolean isDeleted, Pageable pageable); Page<IpResource> findByAddrLikeAndIdInAndIsDeletedOrderByPurchasedTimeDesc(String addr, List<String> ipIds, boolean isDeleted, Pageable pageable);
Page<IpResource> findByVendorLikeAndIdInAndIsDeletedOrderByPurchasedTimeDesc(String vendor, List<String> ipIds, boolean isDeleted, Pageable pageable); Page<IpResource> findByVendorLikeAndIdInAndIsDeletedOrderByPurchasedTimeDesc(String vendor, List<String> ipIds, boolean isDeleted, Pageable pageable);
Page<IpResource> findByRegionLikeAndIdInAndIsDeletedOrderByPurchasedTimeDesc(String region, List<String> ipIds, boolean isDeleted, Pageable pageable); Page<IpResource> findByRegionCnLikeAndIdInAndIsDeletedOrderByPurchasedTimeDesc(String region, List<String> ipIds, boolean isDeleted, Pageable pageable);
List<IpResource> findByStatusAndLockedAndLockTimestampLessThan(int status, boolean locked, long timestamp); List<IpResource> findByStatusAndLockedAndLockTimestampLessThan(int status, boolean locked, long timestamp);
......
...@@ -8,7 +8,7 @@ import org.springframework.data.mongodb.repository.MongoRepository; ...@@ -8,7 +8,7 @@ import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.List; import java.util.List;
public interface ShopRepository extends MongoRepository<Shop, String> { public interface ShopRepository extends MongoRepository<Shop, String> {
Page<Shop> findByShopIdInAndIpRegionLikeOrderByCreateTimeDesc(List<String> shopIds, String ipRegion, Pageable pageable); Page<Shop> findByShopIdInAndIpRegionCnLikeOrderByCreateTimeDesc(List<String> shopIds, String ipRegion, Pageable pageable);
Page<Shop> findByShopIdInAndShopAccountLikeOrderByCreateTimeDesc(List<String> shopIds, String shopAccount, Pageable pageable); Page<Shop> findByShopIdInAndShopAccountLikeOrderByCreateTimeDesc(List<String> shopIds, String shopAccount, Pageable pageable);
Page<Shop> findByShopIdInAndShopNameLikeOrderByCreateTimeDesc(List<String> shopIds, String shopName, Pageable pageable); Page<Shop> findByShopIdInAndShopNameLikeOrderByCreateTimeDesc(List<String> shopIds, String shopName, Pageable pageable);
Page<Shop> findByShopIdInOrderByCreateTimeDesc(List<String> shopIds, Pageable pageable); Page<Shop> findByShopIdInOrderByCreateTimeDesc(List<String> shopIds, Pageable pageable);
......
...@@ -475,7 +475,7 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -475,7 +475,7 @@ public class IpResourceServiceImpl implements IpResourceService {
List<String> allIpIds = ipResources.stream().map(x -> x.getId()).collect(Collectors.toList()); List<String> allIpIds = ipResources.stream().map(x -> x.getId()).collect(Collectors.toList());
Page<IpResource> ipResources1 = null; Page<IpResource> ipResources1 = null;
if (ipFilterDto != null && StringUtils.isNotBlank(ipFilterDto.getRegion())) { if (ipFilterDto != null && StringUtils.isNotBlank(ipFilterDto.getRegion())) {
ipResources1 = ipResourceRepository.findByRegionLikeAndIdInAndIsDeletedOrderByPurchasedTimeDesc(ipFilterDto.getRegion(), allIpIds, false, pageable); ipResources1 = ipResourceRepository.findByRegionCnLikeAndIdInAndIsDeletedOrderByPurchasedTimeDesc(ipFilterDto.getRegion(), allIpIds, false, pageable);
} }
else if (ipFilterDto != null && StringUtils.isNotBlank(ipFilterDto.getAddr())) { else if (ipFilterDto != null && StringUtils.isNotBlank(ipFilterDto.getAddr())) {
ipResources1 = ipResourceRepository.findByAddrLikeAndIdInAndIsDeletedOrderByPurchasedTimeDesc(ipFilterDto.getAddr(), allIpIds, false, pageable); ipResources1 = ipResourceRepository.findByAddrLikeAndIdInAndIsDeletedOrderByPurchasedTimeDesc(ipFilterDto.getAddr(), allIpIds, false, pageable);
...@@ -499,12 +499,12 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -499,12 +499,12 @@ public class IpResourceServiceImpl implements IpResourceService {
} }
if (StringUtils.isNotBlank(x.getAddr())) { if (StringUtils.isNotBlank(x.getAddr())) {
if (x.getValidTime() <= Instant.now().plusSeconds(60*60*24*7).toEpochMilli() && x.getValidTime() >Instant.now().toEpochMilli()) { if (x.getValidTime() <= Instant.now().plusSeconds(60*60*24*7).toEpochMilli() && x.getValidTime() >Instant.now().toEpochMilli()) {
if (x.getStatus() != 5) { if (x.getStatus() != 5 && x.getStatus() != 3 && x.getStatus() != 6) {
x.setStatus(2); x.setStatus(2);
ipResourceRepository.save(x); ipResourceRepository.save(x);
} }
} }
else if (x.getValidTime() <= Instant.now().minusSeconds(60*60*24*7).toEpochMilli()) { else if (x.getValidTime() <= Instant.now().minusSeconds(60*60*24*7).toEpochMilli() && x.getStatus() != 3 && x.getStatus() != 6) {
if (x.getIpType() == IpType.VENDOR) { if (x.getIpType() == IpType.VENDOR) {
IpResourceRequestDto ipResourceRequestDto = new IpResourceRequestDto(); IpResourceRequestDto ipResourceRequestDto = new IpResourceRequestDto();
ipResourceRequestDto.setAddr(Arrays.asList(x.getAddr())); ipResourceRequestDto.setAddr(Arrays.asList(x.getAddr()));
...@@ -516,7 +516,7 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -516,7 +516,7 @@ public class IpResourceServiceImpl implements IpResourceService {
} }
return; return;
} }
else if (x.getValidTime() <= Instant.now().toEpochMilli()) { else if (x.getValidTime() <= Instant.now().toEpochMilli() && x.getStatus() != 3 && x.getStatus() != 6) {
x.setStatus(1); x.setStatus(1);
ipResourceRepository.save(x); ipResourceRepository.save(x);
} }
......
...@@ -249,6 +249,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -249,6 +249,7 @@ public class ShopServiceImpl implements ShopService {
shop.setIp(ipResource.getAddr()); shop.setIp(ipResource.getAddr());
shop.setIpId(ipResource.getId()); shop.setIpId(ipResource.getId());
shop.setIpRegion(ipResource.getRegion()); shop.setIpRegion(ipResource.getRegion());
shop.setIpRegionCn(ipResource.getRegionCn());
shopRepository.save(shop); shopRepository.save(shop);
ipResource.setShopId(shopId); ipResource.setShopId(shopId);
if (shop.getShopName()!=null) if (shop.getShopName()!=null)
...@@ -299,6 +300,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -299,6 +300,7 @@ public class ShopServiceImpl implements ShopService {
shop.setIp(null); shop.setIp(null);
shop.setIpId(null); shop.setIpId(null);
shop.setIpRegion(null); shop.setIpRegion(null);
shop.setIpRegionCn(null);
ipResource.setShopId(null); ipResource.setShopId(null);
ipResource.setShopName(null); ipResource.setShopName(null);
ipResourceRepository.save(ipResource); ipResourceRepository.save(ipResource);
...@@ -412,7 +414,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -412,7 +414,7 @@ public class ShopServiceImpl implements ShopService {
} }
Page<Shop> shops; Page<Shop> shops;
if (shopFilterDto != null && StringUtils.isNotBlank(shopFilterDto.getIpRegion())) if (shopFilterDto != null && StringUtils.isNotBlank(shopFilterDto.getIpRegion()))
shops = shopRepository.findByShopIdInAndIpRegionLikeOrderByCreateTimeDesc(shopIds, shopFilterDto.getIpRegion(), pageable); shops = shopRepository.findByShopIdInAndIpRegionCnLikeOrderByCreateTimeDesc(shopIds, shopFilterDto.getIpRegion(), 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()))
......
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