Ver código fonte

mongodb访问方式变更

tags/v1.0.0^2
林万龙 3 anos atrás
pai
commit
7e3d83bf8b
1 arquivos alterados com 8 adições e 8 exclusões
  1. +8
    -8
      src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java

+ 8
- 8
src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java Ver arquivo

@@ -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<ProvinceInfoEntity> example = Example.of(query);
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 {
return null;
}
// 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();
} catch (Exception e) {
log.error("获取省份异常:", e);
return null;


Carregando…
Cancelar
Salvar