|
|
@@ -2,6 +2,7 @@ package com.telpo.dipperposition.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
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.ProvinceInfoMapper; |
|
|
|
import com.telpo.dipperposition.service.IProvinceInfoService; |
|
|
@@ -57,13 +58,14 @@ public class ProvinceInfoServiceImpl implements IProvinceInfoService { |
|
|
|
ProvinceInfoEntity query = new ProvinceInfoEntity(); |
|
|
|
query.setProvince(provicne); |
|
|
|
Example<ProvinceInfoEntity> example = Example.of(query); |
|
|
|
// PageRequest pageable = PageRequest.of(0, 1); |
|
|
|
Optional<ProvinceInfoEntity> data = provinceInfoMapper.findOne(example); |
|
|
|
// if (CollectionUtil.isNotEmpty(data.getContent())) { |
|
|
|
// |
|
|
|
// List<ProvinceInfoEntity> provinceInfos = BeanTools.copyList(data.getContent(), ProvinceInfoEntity.class); |
|
|
|
// return provinceInfos.get(0); |
|
|
|
return data.get(); |
|
|
|
PageRequest pageable = PageRequest.of(0, 1); |
|
|
|
Page<ProvinceInfoEntity> data = provinceInfoMapper.findAll(example, pageable); |
|
|
|
if (CollectionUtil.isNotEmpty(data.getContent())) { |
|
|
|
List<ProvinceInfoEntity> records = BeanTools.copyList(data.getContent(), ProvinceInfoEntity.class); |
|
|
|
return records.get(0); |
|
|
|
} else { |
|
|
|
return null; |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("获取省份异常:", e); |
|
|
|
return null; |
|
|
|