JobController extends BaseControllerImpl<Job> { @Override @GetMapping("/{page:[0-9]+}/{size:[0-9]+}") @ApiOperation("分页查询定时任务列表") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") public Result<QueryResult<Job>> query(@ApiParam(value = "页码", required = true) @PathVariable("page") int page, @ApiParam(value = "每页数据条数", required = true) @PathVariable("size") int size, Job model) { return super.query(page, size, model); }  @Autowired void setJobService(JobService jobService); @Override @GetMapping("/dict") @ApiOperation("获取定时任务的数据字典") @PreAuthorize("hasAnyAuthority('" + LIST_PERM + "')") Result<TableInfo> getTableInfo(); @Override @PostMapping @ApiOperation("保存定时任务") @PreAuthorize("hasAnyAuthority('" + ADD_PERM + "')") Result<Job> save(@Valid @RequestBody Job 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<Job> update(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id, @RequestBody Job model) {; @Override @GetMapping @ApiOperation("查询所有定时任务") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<List<Job>> findAll(Job model); @Override @GetMapping("/{page:[0-9]+}/{size:[0-9]+}") @ApiOperation("分页查询定时任务列表") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<QueryResult<Job>> query(@ApiParam(value = "页码", required = true) @PathVariable("page") int page, @ApiParam(value = "每页数据条数", required = true) @PathVariable("size") int size, Job model) {; @Override @GetMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("根据ID查询定时任务") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<Job> findById(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) {; @Override @PostMapping("/batch") @ApiOperation("批量操作定时任务") @PreAuthorize("hasAuthority('" + ADD_PERM +"') and hasAuthority('" + EDIT_PERM +"') and hasAuthority('" + DELETE_PERM +"')") Result batch(@RequestBody BatchModel<Job> batch); @PostMapping("/execute/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("立即执行定时任务") @PreAuthorize("hasRole('ADMIN')") Result<String> execute(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) thr; @PostMapping("/pause/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("暂停定时任务") @PreAuthorize("hasRole('ADMIN')") Result<String> pause(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) thr; @PostMapping("/stop/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("停止定时任务") @PreAuthorize("hasRole('ADMIN')") Result<String> stop(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) thr; @PostMapping("/resume/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("恢复定时任务") @PreAuthorize("hasRole('ADMIN')") Result<String> resume(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) thr; @PostMapping("/start/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("开启定时任务") @PreAuthorize("hasRole('ADMIN')") Result<String> start(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) thr; @Override @PostMapping("/import") @ApiOperation("从文件导入定时任务") @PreAuthorize("hasAnyAuthority('" + IMPORT_PERM + "')") Result<List<Job>> 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; Job job = new Job(); String content = objectMapper.writeValueAsString(job); String result = mockMvc.perform(get("/monitor/job/"+ 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); }