|
- package com.telpo.dipperposition.service.impl;
-
- import com.telpo.dipperposition.entity.mongo.IPProvinceEntity;
- 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.stereotype.Service;
-
- import java.util.List;
-
- /**
- * @program: DataPushServer
- * @description: 推送记录服务接口实现类
- * @author: linwl
- * @create: 2020-07-20 11:09
- */
- @Slf4j
- @Service
- public class IpProvinceServiceImpl implements IpProvinceService {
-
- @Autowired
- private IpProvinceMapper ipProvinceMapper;
-
- private static IpProvinceService ipProvinceService;
- /**
- * spring会自动从ioc容器当中根据IPProvinceService类型找到ipProvinceService,当做参数传进来
- *
- */
- @Override
- public void setIPProvinceService(IpProvinceService ipProvinceService) {
- this.ipProvinceService = ipProvinceService;
- }
- @Override
- public boolean saveIpProvince(IPProvinceEntity entity) {
- ipProvinceMapper.saveIp(entity);
- return true;
- }
-
- @Override
- public boolean updateIPProvince(
- IPProvinceEntity query, IPProvinceEntity update) {
-
- ipProvinceMapper.updateIpFirst(query, update);
- return true;
- }
-
- @Override
- public boolean romveById(String id) {
-
- ipProvinceMapper.deleteIpById(id);
- return false;
- }
-
- @Override
- public IPProvinceEntity getIpProvince(String ipAddress) {
- try {
- IPProvinceEntity query = new IPProvinceEntity();
- query.setIp(ipAddress);
-
- List<IPProvinceEntity> pushRecords = ipProvinceMapper.queryIpList(query);
- if (ObjectUtils.isNotEmpty(pushRecords)) {
- return pushRecords.get(0);
- } else {
- return null;
- }
- } catch (Exception e) {
- log.error("获取IP省份异常:", e);
- return null;
- }
- }
- }
|