DepartmentController extends TreeControllerImpl<Department> { @Override @GetMapping("/{page:[0-9]+}/{size:[0-9]+}") @ApiOperation("分页查询部门列表") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") public Result<QueryResult<Department>> query(@ApiParam(value = "页码", required = true) @PathVariable("page") int page, @ApiParam(value = "每页数据条数", required = true) @PathVariable("size") int size, Department model) { return super.query(page, size, model); }  @Autowired void setDepartmentService(DepartmentService departmentService); @Override @GetMapping("/dict") @ApiOperation("获取部门的数据字典") @PreAuthorize("hasAnyAuthority('" + LIST_PERM + "')") Result<TableInfo> getTableInfo(); @Override @PostMapping @ApiOperation("保存部门") @PreAuthorize("hasAnyAuthority('" + ADD_PERM + "')") Result<Department> save(@Valid @RequestBody Department model); @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<Department> update(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id, @RequestBody Department model) {; @Override @GetMapping @ApiOperation("查询所有部门") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<List<Department>> findAll(Department model); @Override @GetMapping("/{page:[0-9]+}/{size:[0-9]+}") @ApiOperation("分页查询部门列表") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<QueryResult<Department>> query(@ApiParam(value = "页码", required = true) @PathVariable("page") int page, @ApiParam(value = "每页数据条数", required = true) @PathVariable("size") int size, Department model) {; @Override @GetMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("根据ID查询部门") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<Department> findById(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) {; @Override @GetMapping("/tree") @ApiOperation("获取树形结构的部门") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<List<Department>> treeData(Department model); @Override @PostMapping("/batch") @ApiOperation("批量操作数据") @PreAuthorize("hasAuthority('" + ADD_PERM +"') and hasAuthority('" + EDIT_PERM +"') and hasAuthority('" + DELETE_PERM +"')") Result batch(@RequestBody BatchModel<Department> batch); @Override @PostMapping("/import") @ApiOperation("从文件导入部门") @PreAuthorize("hasAnyAuthority('" + IMPORT_PERM + "')") Result<List<Department>> 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; Department department = new Department(); String content = objectMapper.writeValueAsString(department); String result = mockMvc.perform(get("/sys/department/"+ 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); }