@Test public void createBook() throws Exception { CreateOrUpdateBookDTO dto = new CreateOrUpdateBookDTO(); dto.setAuthor(author); dto.setImage(image); dto.setSummary(summary); dto.setTitle(title); ObjectMapper mapper = new ObjectMapper(); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); String content = mapper.writeValueAsString(dto); mvc.perform(post("/v1/book/") .contentType(MediaType.APPLICATION_JSON).content(content)) .andDo(print()) .andExpect(status().isOk()) .andExpect(MockMvcResultMatchers. jsonPath("$.message").value("新建图书成功")); }
@PostMapping("") public UnifyResponseVO createBook(@RequestBody @Validated CreateOrUpdateBookDTO validator) { bookService.createBook(validator); return ResponseUtil.generateUnifyResponse(10); }
BookController { @PostMapping("") public UnifyResponseVO createBook(@RequestBody @Validated CreateOrUpdateBookDTO validator) { bookService.createBook(validator); return ResponseUtil.generateUnifyResponse(10); } }
BookController { @PostMapping("") public UnifyResponseVO createBook(@RequestBody @Validated CreateOrUpdateBookDTO validator) { bookService.createBook(validator); return ResponseUtil.generateUnifyResponse(10); }  }
BookController { @PostMapping("") public UnifyResponseVO createBook(@RequestBody @Validated CreateOrUpdateBookDTO validator) { bookService.createBook(validator); return ResponseUtil.generateUnifyResponse(10); }  @GetMapping("/{id}") BookDO getBook(@PathVariable(value = "id") @Positive(message = "{id}") Long id); @GetMapping("") List<BookDO> getBooks(); @GetMapping("/search") List<BookDO> searchBook(@RequestParam(value = "q", required = false, defaultValue = "") String q); @PostMapping("") UnifyResponseVO createBook(@RequestBody @Validated CreateOrUpdateBookDTO validator); @PutMapping("/{id}") UnifyResponseVO updateBook(@PathVariable("id") @Positive(message = "{id}") Long id, @RequestBody @Validated CreateOrUpdateBookDTO validator); @DeleteMapping("/{id}") @RouteMeta(permission = "删除图书", module = "图书", mount = true) @GroupRequired UnifyResponseVO deleteBook(@PathVariable("id") @Positive(message = "{id}") Long id); }
BookController { @PostMapping("") public UnifyResponseVO createBook(@RequestBody @Validated CreateOrUpdateBookDTO validator) { bookService.createBook(validator); return ResponseUtil.generateUnifyResponse(10); }  @GetMapping("/{id}") BookDO getBook(@PathVariable(value = "id") @Positive(message = "{id}") Long id); @GetMapping("") List<BookDO> getBooks(); @GetMapping("/search") List<BookDO> searchBook(@RequestParam(value = "q", required = false, defaultValue = "") String q); @PostMapping("") UnifyResponseVO createBook(@RequestBody @Validated CreateOrUpdateBookDTO validator); @PutMapping("/{id}") UnifyResponseVO updateBook(@PathVariable("id") @Positive(message = "{id}") Long id, @RequestBody @Validated CreateOrUpdateBookDTO validator); @DeleteMapping("/{id}") @RouteMeta(permission = "删除图书", module = "图书", mount = true) @GroupRequired UnifyResponseVO deleteBook(@PathVariable("id") @Positive(message = "{id}") Long id);  }