mirror of
https://github.com/JeffLi1993/springboot-learning-example.git
synced 2026-03-13 21:43:45 +08:00
Spring Boot WebFlux 实现 Restful 服务,基于 HTTP / JSON 传输
This commit is contained in:
@@ -3,7 +3,6 @@ package org.spring.springboot.domain;
|
||||
/**
|
||||
* 城市实体类
|
||||
*
|
||||
* Created by bysocket on 09/29/2017.
|
||||
*/
|
||||
public class City {
|
||||
|
||||
|
||||
@@ -22,14 +22,11 @@ public class CityHandler {
|
||||
}
|
||||
|
||||
public Mono<City> findCityById(Long id) {
|
||||
return Mono.create(cityMonoSink -> cityMonoSink.success(cityRepository.findCityById(id)));
|
||||
return Mono.justOrEmpty(cityRepository.findCityById(id));
|
||||
}
|
||||
|
||||
public Flux<City> findAllCity() {
|
||||
return Flux.create(cityFluxSink -> {
|
||||
cityRepository.findAll().forEach(city -> cityFluxSink.next(city));
|
||||
cityFluxSink.complete();
|
||||
});
|
||||
return Flux.fromIterable(cityRepository.findAll());
|
||||
}
|
||||
|
||||
public Mono<Long> modifyCity(City city) {
|
||||
|
||||
Reference in New Issue
Block a user