@Test public void getPage() throws Exception { mockMvc.perform(get("/tags?page=1&count=5")) .andExpect(status().is(200)) .andDo(result -> { JSONObject articlesJSON = JSONObject.fromObject(result.getResponse().getContentAsString()); assertEquals(SUCCESS.getCode(), articlesJSON.getInt(Code)); assertNotNull(articlesJSON.getJSONObject(Result)); JSONObject resultJson = JSONObject.fromObject(articlesJSON.getJSONObject(Result)); PageInfo pageInfo = (PageInfo) JSONObject.toBean(resultJson, PageInfo.class); assertNotEquals(0, pageInfo.getTotal()); assertNotEquals(0, pageInfo.getStartRow()); assertNotEquals(0, pageInfo.getEndRow()); assertEquals(1, pageInfo.getPageNum()); assertEquals(5, pageInfo.getPageSize()); for (Object tag : pageInfo.getList()) { Tag t = (Tag) JSONObject.toBean(JSONObject.fromObject(tag), Tag.class); assertNotNull(t.getId()); assertNotNull(t.getName()); } }); }
@GetMapping("/tags") public Response getPage(@RequestParam(required = false, defaultValue = "10", value = "count") int count, @RequestParam(required = false, defaultValue = "1", value = "page") int page) { return ResponseUtil.success(tagService.retrievePage(page, count)); }
TagController { @GetMapping("/tags") public Response getPage(@RequestParam(required = false, defaultValue = "10", value = "count") int count, @RequestParam(required = false, defaultValue = "1", value = "page") int page) { return ResponseUtil.success(tagService.retrievePage(page, count)); } }
TagController { @GetMapping("/tags") public Response getPage(@RequestParam(required = false, defaultValue = "10", value = "count") int count, @RequestParam(required = false, defaultValue = "1", value = "page") int page) { return ResponseUtil.success(tagService.retrievePage(page, count)); }  }
TagController { @GetMapping("/tags") public Response getPage(@RequestParam(required = false, defaultValue = "10", value = "count") int count, @RequestParam(required = false, defaultValue = "1", value = "page") int page) { return ResponseUtil.success(tagService.retrievePage(page, count)); }  @PostMapping("/admin/tag/create") Response addOne(@RequestParam("name") String name); @DeleteMapping("/admin/tag/del") Response delOne(@RequestParam("id") long id); @PutMapping("/admin/tag/update") Response updateOne(@RequestParam("id") Long id, @RequestParam("name") String name); @GetMapping("/tag/id/{id}") Response retrieveOneById(@PathVariable("id") long id); @GetMapping("/tag/name/{name}") Response retrieveOneByName(@PathVariable("name") String name); @GetMapping("/tags") Response getPage(@RequestParam(required = false, defaultValue = "10", value = "count") int count,
                            @RequestParam(required = false, defaultValue = "1", value = "page") int page); @GetMapping("/tags/nac") Response getTagNameAndCount(); }
TagController { @GetMapping("/tags") public Response getPage(@RequestParam(required = false, defaultValue = "10", value = "count") int count, @RequestParam(required = false, defaultValue = "1", value = "page") int page) { return ResponseUtil.success(tagService.retrievePage(page, count)); }  @PostMapping("/admin/tag/create") Response addOne(@RequestParam("name") String name); @DeleteMapping("/admin/tag/del") Response delOne(@RequestParam("id") long id); @PutMapping("/admin/tag/update") Response updateOne(@RequestParam("id") Long id, @RequestParam("name") String name); @GetMapping("/tag/id/{id}") Response retrieveOneById(@PathVariable("id") long id); @GetMapping("/tag/name/{name}") Response retrieveOneByName(@PathVariable("name") String name); @GetMapping("/tags") Response getPage(@RequestParam(required = false, defaultValue = "10", value = "count") int count,
                            @RequestParam(required = false, defaultValue = "1", value = "page") int page); @GetMapping("/tags/nac") Response getTagNameAndCount();  }