Selaa lähdekoodia

mongodb访问方式变更

tags/v1.0.0^2
林万龙 3 vuotta sitten
vanhempi
commit
b41432dbde
4 muutettua tiedostoa jossa 22 lisäystä ja 31 poistoa
  1. +1
    -3
      src/main/java/com/telpo/dipperposition/service/IProvinceInfoService.java
  2. +0
    -10
      src/main/java/com/telpo/dipperposition/service/IpProvinceService.java
  3. +14
    -14
      src/main/java/com/telpo/dipperposition/service/impl/IpProvinceServiceImpl.java
  4. +7
    -4
      src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java

+ 1
- 3
src/main/java/com/telpo/dipperposition/service/IProvinceInfoService.java Näytä tiedosto

@@ -27,11 +27,9 @@ public interface IProvinceInfoService {
* 更新省份经纬度信息
*
* @param query
* @param update
* @return
*/
boolean updateProvinceInfoEntity(
ProvinceInfoEntity query, ProvinceInfoEntity update);
boolean updateProvinceInfoEntity(ProvinceInfoEntity query);

/**
* 根据ID移除IP省份记录


+ 0
- 10
src/main/java/com/telpo/dipperposition/service/IpProvinceService.java Näytä tiedosto

@@ -21,16 +21,6 @@ public interface IpProvinceService {
*/
boolean saveIpProvince(IpProvinceEntity entity);

/**
* 更新IP省份
*
* @param query
* @param update
* @return
*/
boolean updateIPProvince(
IpProvinceEntity query, IpProvinceEntity update);

/**
* 根据ID移除IP省份记录
*


+ 14
- 14
src/main/java/com/telpo/dipperposition/service/impl/IpProvinceServiceImpl.java Näytä tiedosto

@@ -1,12 +1,18 @@
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.ProvinceInfoEntity;
import com.telpo.dipperposition.mapper.IpProvinceMapper;
import com.telpo.dipperposition.service.IpProvinceService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
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 tools.BeanTools;

import java.util.List;

@@ -34,22 +40,14 @@ public class IpProvinceServiceImpl implements IpProvinceService {
// }
@Override
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;
}

@Override
public boolean romveById(String id) {

ipProvinceMapper.deleteIpById(id);
ipProvinceMapper.deleteById(id);
return false;
}

@@ -58,10 +56,12 @@ public class IpProvinceServiceImpl implements IpProvinceService {
try {
IpProvinceEntity query = new IpProvinceEntity();
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 {
return null;
}


+ 7
- 4
src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java Näytä tiedosto

@@ -32,11 +32,14 @@ public class ProvinceInfoServiceImpl implements IProvinceInfoService {

@Override
public boolean saveProvinceInfo(ProvinceInfoEntity entity) {

provinceInfoMapper.save(entity);
return false;
}

@Override
public boolean updateProvinceInfoEntity(ProvinceInfoEntity query, ProvinceInfoEntity update) {
public boolean updateProvinceInfoEntity(ProvinceInfoEntity entity) {
provinceInfoMapper.save(entity);
return false;
}

@@ -53,9 +56,9 @@ public class ProvinceInfoServiceImpl implements IProvinceInfoService {
ProvinceInfoEntity query = new ProvinceInfoEntity();
query.setProvince(provicne);
Example<ProvinceInfoEntity> example = Example.of(query);
PageRequest pageable = PageRequest.of(0, 1);
Page<ProvinceInfoEntity> data = provinceInfoMapper.findAll(example, pageable);
if (CollectionUtil.isNotEmpty(data.getContent())) {
PageRequest pageable = PageRequest.of(0, 1);
Page<ProvinceInfoEntity> data = provinceInfoMapper.findAll(example, pageable);
if (CollectionUtil.isNotEmpty(data.getContent())) {
List<ProvinceInfoEntity> provinceInfos = BeanTools.copyList(data.getContent(), ProvinceInfoEntity.class);
return provinceInfos.get(0);
} else {


Loading…
Peruuta
Tallenna