Skip to content

Commit

Permalink
spring webflux 示例
Browse files Browse the repository at this point in the history
  • Loading branch information
YunaiV committed Nov 24, 2019
1 parent 7500151 commit d90c9b1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ public Mono<Integer> add(@RequestBody Publisher<UserAddDTO> addDTO) {
return Mono.just(returnId);
}

/**
* 添加用户
*
* @param addDTO 添加用户信息 DTO
* @return 添加成功的用户编号
*/
@PostMapping("add2")
public Mono<Integer> add2(Mono<UserAddDTO> addDTO) {
// 插入用户记录,返回编号
Integer returnId = UUID.randomUUID().hashCode();
// 返回用户编号
return Mono.just(returnId);
}

/**
* 更新指定用户编号的用户
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import cn.iocoder.springboot.lab27.springwebflux.vo.UserVO;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
import org.springframework.web.reactive.function.server.*;
import reactor.core.publisher.Mono;
Expand All @@ -11,11 +11,14 @@
import java.util.List;
import java.util.UUID;

import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
import static org.springframework.web.reactive.function.server.ServerResponse.ok;
import static org.springframework.web.reactive.function.server.RequestPredicates.*;
import static org.springframework.web.reactive.function.server.RouterFunctions.*;
import static org.springframework.web.reactive.function.server.ServerResponse.*;

@Component
/**
* 用户 Router
*/
@Configuration
public class UserRouter {

@Bean
Expand Down

0 comments on commit d90c9b1

Please sign in to comment.