@Test public void testList() { webClient.get().uri("/users/list") .exchange() .expectStatus().isOk() .expectBody().json("[\n" + " {\n" + " \"id\": 1,\n" + " \"username\": \"yudaoyuanma\"\n" + " },\n" + " {\n" + " \"id\": 2,\n" + " \"username\": \"woshiyutou\"\n" + " },\n" + " {\n" + " \"id\": 3,\n" + " \"username\": \"chifanshuijiao\"\n" + " }\n" + "]"); }
@GetMapping("/list") public Flux<UserVO> list() { List<UserVO> result = new ArrayList<>(); result.add(new UserVO().setId(1).setUsername("yudaoyuanma")); result.add(new UserVO().setId(2).setUsername("woshiyutou")); result.add(new UserVO().setId(3).setUsername("chifanshuijiao")); return Flux.fromIterable(result); }
UserController { @GetMapping("/list") public Flux<UserVO> list() { List<UserVO> result = new ArrayList<>(); result.add(new UserVO().setId(1).setUsername("yudaoyuanma")); result.add(new UserVO().setId(2).setUsername("woshiyutou")); result.add(new UserVO().setId(3).setUsername("chifanshuijiao")); return Flux.fromIterable(result); } }
UserController { @GetMapping("/list") public Flux<UserVO> list() { List<UserVO> result = new ArrayList<>(); result.add(new UserVO().setId(1).setUsername("yudaoyuanma")); result.add(new UserVO().setId(2).setUsername("woshiyutou")); result.add(new UserVO().setId(3).setUsername("chifanshuijiao")); return Flux.fromIterable(result); }  }
UserController { @GetMapping("/list") public Flux<UserVO> list() { List<UserVO> result = new ArrayList<>(); result.add(new UserVO().setId(1).setUsername("yudaoyuanma")); result.add(new UserVO().setId(2).setUsername("woshiyutou")); result.add(new UserVO().setId(3).setUsername("chifanshuijiao")); return Flux.fromIterable(result); }  @GetMapping("/list") Flux<UserVO> list(); @GetMapping("/get") Mono<UserVO> get(@RequestParam("id") Integer id); @GetMapping("/v2/get") Mono<UserVO> get2(@RequestParam("id") Integer id); @PostMapping("add") Mono<Integer> add(@RequestBody Publisher<UserAddDTO> addDTO); @PostMapping("add2") Mono<Integer> add2(Mono<UserAddDTO> addDTO); @PostMapping("/update") Mono<Boolean> update(@RequestBody Publisher<UserUpdateDTO> updateDTO); @PostMapping("/delete") // URL 修改成 /delete ，RequestMethod 改成 DELETE Mono<Boolean> delete(@RequestParam("id") Integer id); }
UserController { @GetMapping("/list") public Flux<UserVO> list() { List<UserVO> result = new ArrayList<>(); result.add(new UserVO().setId(1).setUsername("yudaoyuanma")); result.add(new UserVO().setId(2).setUsername("woshiyutou")); result.add(new UserVO().setId(3).setUsername("chifanshuijiao")); return Flux.fromIterable(result); }  @GetMapping("/list") Flux<UserVO> list(); @GetMapping("/get") Mono<UserVO> get(@RequestParam("id") Integer id); @GetMapping("/v2/get") Mono<UserVO> get2(@RequestParam("id") Integer id); @PostMapping("add") Mono<Integer> add(@RequestBody Publisher<UserAddDTO> addDTO); @PostMapping("add2") Mono<Integer> add2(Mono<UserAddDTO> addDTO); @PostMapping("/update") Mono<Boolean> update(@RequestBody Publisher<UserUpdateDTO> updateDTO); @PostMapping("/delete") // URL 修改成 /delete ，RequestMethod 改成 DELETE Mono<Boolean> delete(@RequestParam("id") Integer id);  }