mirror of
https://github.com/JeffLi1993/springboot-learning-example.git
synced 2026-03-14 14:13:52 +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 {
|
public class City {
|
||||||
|
|
||||||
|
|||||||
@@ -22,14 +22,11 @@ public class CityHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Mono<City> findCityById(Long id) {
|
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() {
|
public Flux<City> findAllCity() {
|
||||||
return Flux.create(cityFluxSink -> {
|
return Flux.fromIterable(cityRepository.findAll());
|
||||||
cityRepository.findAll().forEach(city -> cityFluxSink.next(city));
|
|
||||||
cityFluxSink.complete();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mono<Long> modifyCity(City city) {
|
public Mono<Long> modifyCity(City city) {
|
||||||
|
|||||||
Reference in New Issue
Block a user