Sfoglia il codice sorgente

mongodb访问方式变更

tags/v1.0.0^2
林万龙 3 anni fa
parent
commit
7e3d83bf8b
1 ha cambiato i file con 8 aggiunte e 8 eliminazioni
  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 Vedi File

@@ -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;


Loading…
Annulla
Salva