File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
lab-27/lab-27-webflux-01/src/main/java/cn/iocoder/springboot/lab27/springwebflux/controller Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 3
3
import cn .iocoder .springboot .lab27 .springwebflux .dto .UserAddDTO ;
4
4
import cn .iocoder .springboot .lab27 .springwebflux .dto .UserUpdateDTO ;
5
5
import cn .iocoder .springboot .lab27 .springwebflux .vo .UserVO ;
6
+ import org .reactivestreams .Publisher ;
6
7
import org .springframework .web .bind .annotation .*;
7
8
import reactor .core .publisher .Flux ;
8
9
import reactor .core .publisher .Mono ;
@@ -55,7 +56,7 @@ public Mono<UserVO> get(@RequestParam("id") Integer id) {
55
56
* @return 添加成功的用户编号
56
57
*/
57
58
@ PostMapping ("add" )
58
- public Mono <Integer > add (UserAddDTO addDTO ) {
59
+ public Mono <Integer > add (@ RequestBody Publisher < UserAddDTO > addDTO ) {
59
60
// 插入用户记录,返回编号
60
61
Integer returnId = UUID .randomUUID ().hashCode ();
61
62
// 返回用户编号
@@ -69,7 +70,7 @@ public Mono<Integer> add(UserAddDTO addDTO) {
69
70
* @return 是否修改成功
70
71
*/
71
72
@ PostMapping ("/update" )
72
- public Mono <Boolean > update (UserUpdateDTO updateDTO ) {
73
+ public Mono <Boolean > update (@ RequestBody Publisher < UserUpdateDTO > updateDTO ) {
73
74
// 更新用户记录
74
75
Boolean success = true ;
75
76
// 返回更新是否成功
Original file line number Diff line number Diff line change 1
- package cn .iocoder .springboot .lab27 .springwebflux .config ;
1
+ package cn .iocoder .springboot .lab27 .springwebflux .controller ;
2
2
3
3
import cn .iocoder .springboot .lab27 .springwebflux .vo .UserVO ;
4
4
import org .springframework .context .annotation .Bean ;
5
- import org .springframework .context . annotation . Configuration ;
5
+ import org .springframework .stereotype . Component ;
6
6
import org .springframework .util .StringUtils ;
7
7
import org .springframework .web .reactive .function .server .*;
8
8
import reactor .core .publisher .Mono ;
15
15
import static org .springframework .web .reactive .function .server .RouterFunctions .route ;
16
16
import static org .springframework .web .reactive .function .server .ServerResponse .ok ;
17
17
18
- @ Configuration
19
- public class WebFluxRouteConfiguration {
18
+ @ Component
19
+ public class UserRouter {
20
20
21
21
@ Bean
22
22
public RouterFunction <ServerResponse > userListRouterFunction () {
You can’t perform that action at this time.
0 commit comments