From 44bbe8b3078e7727db354f5ec5f40e3bfd6de512 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期四, 17 六月 2021 19:22:49 +0800 Subject: [PATCH] update 同步更新 ruoyi 适配新功能 --- ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java | 288 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 144 insertions(+), 144 deletions(-) diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java index 97be717..2725cd8 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java @@ -1,144 +1,144 @@ -package com.ruoyi.quartz.controller; - -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.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.exception.job.TaskException; -import com.ruoyi.common.utils.SecurityUtils; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.quartz.domain.SysJob; -import com.ruoyi.quartz.service.ISysJobService; -import com.ruoyi.quartz.util.CronUtils; -import org.quartz.SchedulerException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 璋冨害浠诲姟淇℃伅鎿嶄綔澶勭悊 - * - * @author ruoyi - */ -@RestController -@RequestMapping("/monitor/job") -public class SysJobController extends BaseController -{ - @Autowired - private ISysJobService jobService; - - /** - * 鏌ヨ瀹氭椂浠诲姟鍒楄〃 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:list')") - @GetMapping("/list") - public TableDataInfo list(SysJob sysJob) - { - return jobService.selectPageJobList(sysJob); - } - - /** - * 瀵煎嚭瀹氭椂浠诲姟鍒楄〃 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:export')") - @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.EXPORT) - @GetMapping("/export") - public AjaxResult export(SysJob sysJob) - { - List<SysJob> list = jobService.selectJobList(sysJob); - ExcelUtil<SysJob> util = new ExcelUtil<SysJob>(SysJob.class); - return util.exportExcel(list, "瀹氭椂浠诲姟"); - } - - /** - * 鑾峰彇瀹氭椂浠诲姟璇︾粏淇℃伅 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:query')") - @GetMapping(value = "/{jobId}") - public AjaxResult getInfo(@PathVariable("jobId") Long jobId) - { - return AjaxResult.success(jobService.selectJobById(jobId)); - } - - /** - * 鏂板瀹氭椂浠诲姟 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:add')") - @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException - { - if (!CronUtils.isValid(sysJob.getCronExpression())) - { - return AjaxResult.error("鏂板浠诲姟'" + sysJob.getJobName() + "'澶辫触锛孋ron琛ㄨ揪寮忎笉姝g‘"); - } - else if (StringUtils.containsIgnoreCase(sysJob.getInvokeTarget(), Constants.LOOKUP_RMI)) - { - return AjaxResult.error("鏂板浠诲姟'" + sysJob.getJobName() + "'澶辫触锛岀洰鏍囧瓧绗︿覆涓嶅厑璁�'rmi://'璋冪敤"); - } - sysJob.setCreateBy(SecurityUtils.getUsername()); - return toAjax(jobService.insertJob(sysJob)); - } - - /** - * 淇敼瀹氭椂浠诲姟 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:edit')") - @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException - { - if (!CronUtils.isValid(sysJob.getCronExpression())) - { - return AjaxResult.error("淇敼浠诲姟'" + sysJob.getJobName() + "'澶辫触锛孋ron琛ㄨ揪寮忎笉姝g‘"); - } - else if (StringUtils.containsIgnoreCase(sysJob.getInvokeTarget(), Constants.LOOKUP_RMI)) - { - return AjaxResult.error("淇敼浠诲姟'" + sysJob.getJobName() + "'澶辫触锛岀洰鏍囧瓧绗︿覆涓嶅厑璁�'rmi://'璋冪敤"); - } - sysJob.setUpdateBy(SecurityUtils.getUsername()); - return toAjax(jobService.updateJob(sysJob)); - } - - /** - * 瀹氭椂浠诲姟鐘舵�佷慨鏀� - */ - @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") - @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.UPDATE) - @PutMapping("/changeStatus") - public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException - { - SysJob newJob = jobService.selectJobById(job.getJobId()); - newJob.setStatus(job.getStatus()); - return toAjax(jobService.changeStatus(newJob)); - } - - /** - * 瀹氭椂浠诲姟绔嬪嵆鎵ц涓�娆� - */ - @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") - @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.UPDATE) - @PutMapping("/run") - public AjaxResult run(@RequestBody SysJob job) throws SchedulerException - { - jobService.run(job); - return AjaxResult.success(); - } - - /** - * 鍒犻櫎瀹氭椂浠诲姟 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:remove')") - @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.DELETE) - @DeleteMapping("/{jobIds}") - public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException - { - jobService.deleteJobByIds(jobIds); - return AjaxResult.success(); - } -} +package com.ruoyi.quartz.controller; + +import cn.hutool.core.util.StrUtil; +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.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.exception.job.TaskException; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.quartz.domain.SysJob; +import com.ruoyi.quartz.service.ISysJobService; +import com.ruoyi.quartz.util.CronUtils; +import org.quartz.SchedulerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 璋冨害浠诲姟淇℃伅鎿嶄綔澶勭悊 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/monitor/job") +public class SysJobController extends BaseController +{ + @Autowired + private ISysJobService jobService; + + /** + * 鏌ヨ瀹氭椂浠诲姟鍒楄〃 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:list')") + @GetMapping("/list") + public TableDataInfo list(SysJob sysJob) + { + return jobService.selectPageJobList(sysJob); + } + + /** + * 瀵煎嚭瀹氭椂浠诲姟鍒楄〃 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:export')") + @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(SysJob sysJob) + { + List<SysJob> list = jobService.selectJobList(sysJob); + ExcelUtil<SysJob> util = new ExcelUtil<SysJob>(SysJob.class); + return util.exportExcel(list, "瀹氭椂浠诲姟"); + } + + /** + * 鑾峰彇瀹氭椂浠诲姟璇︾粏淇℃伅 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:query')") + @GetMapping(value = "/{jobId}") + public AjaxResult getInfo(@PathVariable("jobId") Long jobId) + { + return AjaxResult.success(jobService.selectJobById(jobId)); + } + + /** + * 鏂板瀹氭椂浠诲姟 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:add')") + @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException + { + if (!CronUtils.isValid(sysJob.getCronExpression())) + { + return AjaxResult.error("鏂板浠诲姟'" + sysJob.getJobName() + "'澶辫触锛孋ron琛ㄨ揪寮忎笉姝g‘"); + } + else if (StrUtil.containsIgnoreCase(sysJob.getInvokeTarget(), Constants.LOOKUP_RMI)) + { + return AjaxResult.error("鏂板浠诲姟'" + sysJob.getJobName() + "'澶辫触锛岀洰鏍囧瓧绗︿覆涓嶅厑璁�'rmi://'璋冪敤"); + } + sysJob.setCreateBy(SecurityUtils.getUsername()); + return toAjax(jobService.insertJob(sysJob)); + } + + /** + * 淇敼瀹氭椂浠诲姟 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:edit')") + @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException + { + if (!CronUtils.isValid(sysJob.getCronExpression())) + { + return AjaxResult.error("淇敼浠诲姟'" + sysJob.getJobName() + "'澶辫触锛孋ron琛ㄨ揪寮忎笉姝g‘"); + } + else if (StrUtil.containsIgnoreCase(sysJob.getInvokeTarget(), Constants.LOOKUP_RMI)) + { + return AjaxResult.error("淇敼浠诲姟'" + sysJob.getJobName() + "'澶辫触锛岀洰鏍囧瓧绗︿覆涓嶅厑璁�'rmi://'璋冪敤"); + } + sysJob.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(jobService.updateJob(sysJob)); + } + + /** + * 瀹氭椂浠诲姟鐘舵�佷慨鏀� + */ + @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") + @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.UPDATE) + @PutMapping("/changeStatus") + public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException + { + SysJob newJob = jobService.selectJobById(job.getJobId()); + newJob.setStatus(job.getStatus()); + return toAjax(jobService.changeStatus(newJob)); + } + + /** + * 瀹氭椂浠诲姟绔嬪嵆鎵ц涓�娆� + */ + @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") + @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.UPDATE) + @PutMapping("/run") + public AjaxResult run(@RequestBody SysJob job) throws SchedulerException + { + jobService.run(job); + return AjaxResult.success(); + } + + /** + * 鍒犻櫎瀹氭椂浠诲姟 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:remove')") + @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.DELETE) + @DeleteMapping("/{jobIds}") + public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException + { + jobService.deleteJobByIds(jobIds); + return AjaxResult.success(); + } +} -- Gitblit v1.9.3