Browse Source

修改到docker外运行环境

tags/v1.0.0^2
林万龙 3 years ago
parent
commit
1228eb7333
3 changed files with 16 additions and 34 deletions
  1. +4
    -4
      src/main/java/com/telpo/dipperposition/mapper/IpProvinceMapper.java
  2. +2
    -9
      src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java
  3. +10
    -21
      src/main/java/com/telpo/dipperposition/service/impl/IpProvinceServiceImpl.java

src/main/java/com/telpo/dipperposition/mapper/IPProvinceMapper.java → src/main/java/com/telpo/dipperposition/mapper/IpProvinceMapper.java View File

@@ -15,17 +15,17 @@ import java.util.List;
* @create: 2020-07-20 11:12
*/
@Repository
public class IPProvinceMapper extends BaseMongoDbDao<IPProvinceEntity> {
public class IpProvinceMapper extends BaseMongoDbDao<IPProvinceEntity> {

private static IPProvinceMapper iPProvinceMapper;
private static IpProvinceMapper ipProvinceMapper;
/**
* spring会自动从ioc容器当中根据IPProvinceMapper类型找到iPProvinceMapper,
* 当做参数传进来
*
*/
@Autowired
public void setIPProvinceMapper(IPProvinceMapper iPProvinceMapper) {
this.iPProvinceMapper = iPProvinceMapper;
public void setIPProvinceMapper(IpProvinceMapper ipProvinceMapper) {
this.ipProvinceMapper = ipProvinceMapper;
}

@Override

+ 2
- 9
src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java View File

@@ -1,24 +1,17 @@
package com.telpo.dipperposition.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Joiner;
import com.telpo.dipperposition.common.*;
import com.telpo.dipperposition.entity.mongo.IPProvinceEntity;
import com.telpo.dipperposition.mapper.IPProvinceMapper;
import com.telpo.dipperposition.service.IDipperAstPosAsyncTaskService;
import com.telpo.dipperposition.service.IPProvinceService;
import com.telpo.dipperposition.vo.IPProvinceVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.io.UnsupportedEncodingException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
@@ -109,7 +102,7 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS
// 使用时,先在缓存中获取匹配信息
// 用mongodb实现
if(iPProvinceService == null) {
iPProvinceService = new IPProvinceServiceImpl();
iPProvinceService = new IpProvinceServiceImpl();
}
IPProvinceEntity ipProvinceEntity = iPProvinceService.getIpProvince(ipAddress);
if (ipProvinceEntity == null) {
@@ -144,7 +137,7 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS
log.debug("异步创建推送失败任务记录!");
try {
if(iPProvinceService == null) {
iPProvinceService = new IPProvinceServiceImpl();
iPProvinceService = new IpProvinceServiceImpl();
}
IPProvinceEntity ipProvinceEntity = iPProvinceService.getIpProvince(ipAddress);
if (ipProvinceEntity == null) {


src/main/java/com/telpo/dipperposition/service/impl/IPProvinceServiceImpl.java → src/main/java/com/telpo/dipperposition/service/impl/IpProvinceServiceImpl.java View File

@@ -1,10 +1,8 @@
package com.telpo.dipperposition.service.impl;

import com.telpo.dipperposition.entity.mongo.IPProvinceEntity;
import com.telpo.dipperposition.mapper.IPProvinceMapper;
import com.telpo.dipperposition.service.IDipperDataAsyncTaskService;
import com.telpo.dipperposition.mapper.IpProvinceMapper;
import com.telpo.dipperposition.service.IPProvinceService;
import com.telpo.dipperposition.vo.IPProvinceVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -20,10 +18,10 @@ import java.util.List;
*/
@Slf4j
@Service
public class IPProvinceServiceImpl implements IPProvinceService {
public class IpProvinceServiceImpl implements IPProvinceService {

@Autowired
private IPProvinceMapper iPProvinceMapper;
private IpProvinceMapper ipProvinceMapper;

private static IPProvinceService ipProvinceService;
/**
@@ -36,29 +34,22 @@ public class IPProvinceServiceImpl implements IPProvinceService {
}
@Override
public boolean saveIpProvince(IPProvinceEntity entity) {
if (iPProvinceMapper == null) {
iPProvinceMapper = new IPProvinceMapper();
}
iPProvinceMapper.saveIp(entity);
ipProvinceMapper.saveIp(entity);
return true;
}

@Override
public boolean updateIPProvince(
IPProvinceEntity query, IPProvinceEntity update) {
if (iPProvinceMapper == null) {
iPProvinceMapper = new IPProvinceMapper();
}
iPProvinceMapper.updateIpFirst(query, update);

ipProvinceMapper.updateIpFirst(query, update);
return true;
}

@Override
public boolean romveById(String id) {
if (iPProvinceMapper == null) {
iPProvinceMapper = new IPProvinceMapper();
}
iPProvinceMapper.deleteIpById(id);

ipProvinceMapper.deleteIpById(id);
return false;
}

@@ -67,10 +58,8 @@ public class IPProvinceServiceImpl implements IPProvinceService {
try {
IPProvinceEntity query = new IPProvinceEntity();
query.setIp(ipAddress);
if (iPProvinceMapper == null) {
iPProvinceMapper = new IPProvinceMapper();
}
List<IPProvinceEntity> pushRecords = iPProvinceMapper.queryIpList(query);

List<IPProvinceEntity> pushRecords = ipProvinceMapper.queryIpList(query);
if (ObjectUtils.isNotEmpty(pushRecords)) {
return pushRecords.get(0);
} else {

Loading…
Cancel
Save