| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.exception.job.TaskException; |
| | |
| | | |
| | | /** |
| | | * 调度任务信息操作处理 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:query')") |
| | | @GetMapping(value = "/{jobId}") |
| | | public AjaxResult getInfo(@PathVariable("jobId") Long jobId) |
| | | public Result getInfo(@PathVariable("jobId") Long jobId) |
| | | { |
| | | return success(jobService.selectJobById(jobId)); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:add')") |
| | | @Log(title = "定时任务", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody SysJob job) throws SchedulerException, TaskException |
| | | public Result add(@RequestBody SysJob job) throws SchedulerException, TaskException |
| | | { |
| | | if (!CronUtils.isValid(job.getCronExpression())) |
| | | { |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:edit')") |
| | | @Log(title = "定时任务", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody SysJob job) throws SchedulerException, TaskException |
| | | public Result edit(@RequestBody SysJob job) throws SchedulerException, TaskException |
| | | { |
| | | if (!CronUtils.isValid(job.getCronExpression())) |
| | | { |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") |
| | | @Log(title = "定时任务", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException |
| | | public Result changeStatus(@RequestBody SysJob job) throws SchedulerException |
| | | { |
| | | SysJob newJob = jobService.selectJobById(job.getJobId()); |
| | | newJob.setStatus(job.getStatus()); |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") |
| | | @Log(title = "定时任务", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/run") |
| | | public AjaxResult run(@RequestBody SysJob job) throws SchedulerException |
| | | public Result run(@RequestBody SysJob job) throws SchedulerException |
| | | { |
| | | boolean result = jobService.run(job); |
| | | return result ? success() : error("任务不存在或已过期!"); |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:remove')") |
| | | @Log(title = "定时任务", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{jobIds}") |
| | | public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException |
| | | public Result remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException |
| | | { |
| | | jobService.deleteJobByIds(jobIds); |
| | | return success(); |