|
@@ -1,12 +1,18 @@ |
|
|
package com.telpo.dipperposition.service.impl; |
|
|
package com.telpo.dipperposition.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
import com.telpo.dipperposition.entity.mongo.IpProvinceEntity; |
|
|
import com.telpo.dipperposition.entity.mongo.IpProvinceEntity; |
|
|
|
|
|
import com.telpo.dipperposition.entity.mongo.ProvinceInfoEntity; |
|
|
import com.telpo.dipperposition.mapper.IpProvinceMapper; |
|
|
import com.telpo.dipperposition.mapper.IpProvinceMapper; |
|
|
import com.telpo.dipperposition.service.IpProvinceService; |
|
|
import com.telpo.dipperposition.service.IpProvinceService; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.data.domain.Example; |
|
|
|
|
|
import org.springframework.data.domain.Page; |
|
|
|
|
|
import org.springframework.data.domain.PageRequest; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
import tools.BeanTools; |
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
@@ -34,22 +40,14 @@ public class IpProvinceServiceImpl implements IpProvinceService { |
|
|
// } |
|
|
// } |
|
|
@Override |
|
|
@Override |
|
|
public boolean saveIpProvince(IpProvinceEntity entity) { |
|
|
public boolean saveIpProvince(IpProvinceEntity entity) { |
|
|
ipProvinceMapper.saveIp(entity); |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean updateIPProvince( |
|
|
|
|
|
IpProvinceEntity query, IpProvinceEntity update) { |
|
|
|
|
|
|
|
|
|
|
|
ipProvinceMapper.updateIpFirst(query, update); |
|
|
|
|
|
|
|
|
ipProvinceMapper.save(entity); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean romveById(String id) { |
|
|
public boolean romveById(String id) { |
|
|
|
|
|
|
|
|
ipProvinceMapper.deleteIpById(id); |
|
|
|
|
|
|
|
|
ipProvinceMapper.deleteById(id); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -58,10 +56,12 @@ public class IpProvinceServiceImpl implements IpProvinceService { |
|
|
try { |
|
|
try { |
|
|
IpProvinceEntity query = new IpProvinceEntity(); |
|
|
IpProvinceEntity query = new IpProvinceEntity(); |
|
|
query.setIp(ipAddress); |
|
|
query.setIp(ipAddress); |
|
|
|
|
|
|
|
|
List<IpProvinceEntity> pushRecords = ipProvinceMapper.queryIpList(query); |
|
|
|
|
|
if (ObjectUtils.isNotEmpty(pushRecords)) { |
|
|
|
|
|
return pushRecords.get(0); |
|
|
|
|
|
|
|
|
Example<IpProvinceEntity> example = Example.of(query); |
|
|
|
|
|
PageRequest pageable = PageRequest.of(0, 1); |
|
|
|
|
|
Page<IpProvinceEntity> data = ipProvinceMapper.findAll(example, pageable); |
|
|
|
|
|
if (CollectionUtil.isNotEmpty(data.getContent())) { |
|
|
|
|
|
List<IpProvinceEntity> records = BeanTools.copyList(data.getContent(), IpProvinceEntity.class); |
|
|
|
|
|
return records.get(0); |
|
|
} else { |
|
|
} else { |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|