@Test public void testFindById() throws Exception { String id = "{}"; String result = mockMvc.perform(get("/monitor/job/"+ id) .header(HttpHeaders.AUTHORIZATION, String.join(" ", accessToken.getTokenType(), accessToken.getValue())) .contentType(MediaType.APPLICATION_JSON_UTF8) .accept(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()) .andExpect(jsonPath("$.data.id").value(id)) .andReturn().getResponse().getContentAsString(); log.info(result); }
@Override @GetMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("根据ID查询定时任务") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") public Result<Job> findById(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) { return super.findById(id); }
JobController extends BaseControllerImpl<Job> { @Override @GetMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("根据ID查询定时任务") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") public Result<Job> findById(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) { return super.findById(id); } }
JobController extends BaseControllerImpl<Job> { @Override @GetMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("根据ID查询定时任务") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") public Result<Job> findById(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) { return super.findById(id); }  }
JobController extends BaseControllerImpl<Job> { @Override @GetMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("根据ID查询定时任务") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") public Result<Job> findById(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) { return super.findById(id); }  @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); }
JobController extends BaseControllerImpl<Job> { @Override @GetMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("根据ID查询定时任务") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") public Result<Job> findById(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) { return super.findById(id); }  @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);  }