@Test public void searchBook() throws Exception { BookDO bookDO = new BookDO(); bookDO.setTitle(title); bookDO.setAuthor(author); bookDO.setImage(image); bookDO.setSummary(summary); bookMapper.insert(bookDO); this.id = bookDO.getId(); mvc.perform(get("/v1/book/search?q=千里")) .andDo(print()) .andExpect(status().isOk()) .andExpect(MockMvcResultMatchers. jsonPath("$").isArray()); }
@GetMapping("/search") public List<BookDO> searchBook(@RequestParam(value = "q", required = false, defaultValue = "") String q) { List<BookDO> books = bookService.getBookByKeyword("%" + q + "%"); return books; }
BookController { @GetMapping("/search") public List<BookDO> searchBook(@RequestParam(value = "q", required = false, defaultValue = "") String q) { List<BookDO> books = bookService.getBookByKeyword("%" + q + "%"); return books; } }
BookController { @GetMapping("/search") public List<BookDO> searchBook(@RequestParam(value = "q", required = false, defaultValue = "") String q) { List<BookDO> books = bookService.getBookByKeyword("%" + q + "%"); return books; }  }
BookController { @GetMapping("/search") public List<BookDO> searchBook(@RequestParam(value = "q", required = false, defaultValue = "") String q) { List<BookDO> books = bookService.getBookByKeyword("%" + q + "%"); return books; }  @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 { @GetMapping("/search") public List<BookDO> searchBook(@RequestParam(value = "q", required = false, defaultValue = "") String q) { List<BookDO> books = bookService.getBookByKeyword("%" + q + "%"); return books; }  @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);  }