MenuController extends TreeControllerImpl<Menu> { @Override @GetMapping("/{page:[0-9]+}/{size:[0-9]+}") @ApiOperation("分页查询菜单列表") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") public Result<QueryResult<Menu>> query(@ApiParam(value = "页码", required = true) @PathVariable("page") int page, @ApiParam(value = "每页数据条数", required = true) @PathVariable("size") int size, Menu model) { return super.query(page, size, model); }  @Autowired void setMenuService(MenuService menuService); @Override @GetMapping("/dict") @ApiOperation("获取菜单的数据字典") @PreAuthorize("hasAnyAuthority('" + LIST_PERM + "')") Result<TableInfo> getTableInfo(); @Override @PostMapping @ApiOperation("保存菜单") @PreAuthorize("hasAnyAuthority('" + ADD_PERM + "')") Result<Menu> save(@Valid @RequestBody Menu entity); @Override @DeleteMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("删除菜单") @PreAuthorize("hasAnyAuthority('" + DELETE_PERM + "')") Result<Void> delete(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) {; @Override @PutMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("更新菜单") @PreAuthorize("hasAnyAuthority('" + EDIT_PERM + "')") Result<Menu> update(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id, /*@Valid*/@RequestBody Menu model) {; @Override @GetMapping("/{page:[0-9]+}/{size:[0-9]+}") @ApiOperation("分页查询菜单列表") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<QueryResult<Menu>> query(@ApiParam(value = "页码", required = true) @PathVariable("page") int page, @ApiParam(value = "每页数据条数", required = true) @PathVariable("size") int size, /*@RequestBody(required = false) */Menu model) {; @Override @GetMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("根据ID查询菜单") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<Menu> findById(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) {; @Override @GetMapping("/tree") @ApiOperation("获取树形结构的菜单") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<List<Menu>> treeData(Menu menu); @Override @GetMapping @ApiOperation("查询所有菜单") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<List<Menu>> findAll(Menu model); @Override @PostMapping("/batch") @ApiOperation("批量操作数据") @PreAuthorize("hasAuthority('" + ADD_PERM +"') and hasAuthority('" + EDIT_PERM +"') and hasAuthority('" + DELETE_PERM +"')") Result batch(@RequestBody BatchModel<Menu> batch); @GetMapping("/routers") @ApiOperation("获取用户路由菜单") @PreAuthorize("isAuthenticated()") Result<List<Menu>> getRouters(); @GetMapping("/allRouters") @ApiOperation("获取所有路由菜单") @PreAuthorize("isAuthenticated()") Result<List<Menu>> getAllRouters(); @Override @PostMapping("/import") @ApiOperation("从文件导入菜单") @PreAuthorize("hasAnyAuthority('" + IMPORT_PERM + "')") Result<List<Menu>> importData(MultipartFile file); @Override @GetMapping("/export") @ApiOperation("导出菜单到文件") @PreAuthorize("permitAll()") void exportData(@RequestBody(required = false) List<String> ids, HttpServletResponse response);  }
@Test public void testQuery() throws Exception { int page = 1; int size = 10; Menu menu = new Menu(); String content = objectMapper.writeValueAsString(menu); String result = mockMvc.perform(get("/sys/menu/"+ page + "/" + size) .header(HttpHeaders.AUTHORIZATION, String.join(" ", accessToken.getTokenType(), accessToken.getValue())) .content(content) .contentType(MediaType.APPLICATION_JSON_UTF8) .accept(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()) .andExpect(jsonPath("$.data.total").isNumber()) .andReturn().getResponse().getContentAsString(); log.info(result); }