From 7e3d83bf8b37c917ae3f8d312b803fb9e9ac0084 Mon Sep 17 00:00:00 2001 From: linwl <304115325@qq.com> Date: Wed, 20 Jan 2021 20:46:50 +0800 Subject: [PATCH] =?UTF-8?q?mongodb=E8=AE=BF=E9=97=AE=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ProvinceInfoServiceImpl.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java b/src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java index 9ca927e..b124ac9 100644 --- a/src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java +++ b/src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java @@ -15,6 +15,7 @@ import org.springframework.stereotype.Service; import tools.BeanTools; import java.util.List; +import java.util.Optional; /** * @program: DataPushServer @@ -56,14 +57,13 @@ public class ProvinceInfoServiceImpl implements IProvinceInfoService { ProvinceInfoEntity query = new ProvinceInfoEntity(); query.setProvince(provicne); Example example = Example.of(query); - PageRequest pageable = PageRequest.of(0, 1); - Page data = provinceInfoMapper.findAll(example, pageable); - if (CollectionUtil.isNotEmpty(data.getContent())) { - List provinceInfos = BeanTools.copyList(data.getContent(), ProvinceInfoEntity.class); - return provinceInfos.get(0); - } else { - return null; - } +// PageRequest pageable = PageRequest.of(0, 1); + Optional data = provinceInfoMapper.findOne(example); +// if (CollectionUtil.isNotEmpty(data.getContent())) { +// +// List provinceInfos = BeanTools.copyList(data.getContent(), ProvinceInfoEntity.class); +// return provinceInfos.get(0); + return data.get(); } catch (Exception e) { log.error("获取省份异常:", e); return null;