@Test public void updateTest() throws Exception{ Book book = new Book(); book.setId("4"); book.setPrice(130); book.setName("VUE从入门到放弃"); book.setInfo("前端框架--更新"); Gson gson = new Gson(); String params = gson.toJson(book); MvcResult mvcResult = MockUtils.mockPostTest("/mongo/delOne",params,mockMvc); String result = mvcResult.getResponse().getContentAsString(); System.out.println("更新对象-->" + result); }
@PostMapping("/mongo/update") public String update(@RequestBody Book book) { return mongoDbService.updateBook(book); }
MongoDbController { @PostMapping("/mongo/update") public String update(@RequestBody Book book) { return mongoDbService.updateBook(book); } }
MongoDbController { @PostMapping("/mongo/update") public String update(@RequestBody Book book) { return mongoDbService.updateBook(book); }  }
MongoDbController { @PostMapping("/mongo/update") public String update(@RequestBody Book book) { return mongoDbService.updateBook(book); }  @PostMapping("/mongo/save") String saveObj(@RequestBody Book book); @GetMapping("/mongo/findAll") List<Book> findAll(); @GetMapping("/mongo/findOne") Book findOne(@RequestParam String id); @GetMapping("/mongo/findOneByName") Book findOneByName(@RequestParam String name); @PostMapping("/mongo/update") String update(@RequestBody Book book); @PostMapping("/mongo/delOne") String delOne(@RequestBody Book book); @GetMapping("/mongo/delById") String delById(@RequestParam String id); @GetMapping("/mongo/findLikes") List<Book> findByLikes(@RequestParam String search); }
MongoDbController { @PostMapping("/mongo/update") public String update(@RequestBody Book book) { return mongoDbService.updateBook(book); }  @PostMapping("/mongo/save") String saveObj(@RequestBody Book book); @GetMapping("/mongo/findAll") List<Book> findAll(); @GetMapping("/mongo/findOne") Book findOne(@RequestParam String id); @GetMapping("/mongo/findOneByName") Book findOneByName(@RequestParam String name); @PostMapping("/mongo/update") String update(@RequestBody Book book); @PostMapping("/mongo/delOne") String delOne(@RequestBody Book book); @GetMapping("/mongo/delById") String delById(@RequestParam String id); @GetMapping("/mongo/findLikes") List<Book> findByLikes(@RequestParam String search);  }