package cn.stylefeng.guns.modular.zsx.bs.job.controller;
|
|
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
|
import cn.stylefeng.guns.modular.zsx.bs.job.entity.SysJob;
|
import cn.stylefeng.guns.modular.zsx.bs.job.model.params.SysJobParam;
|
import cn.stylefeng.guns.modular.zsx.bs.job.quartz.QuartzUtil;
|
import cn.stylefeng.guns.modular.zsx.bs.job.service.SysJobService;
|
import cn.stylefeng.roses.core.base.controller.BaseController;
|
import cn.stylefeng.roses.core.mutidatasource.annotion.DataSource;
|
import cn.stylefeng.roses.kernel.model.response.ResponseData;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
/**
|
* 定时任务调度表控制器
|
*
|
* @author zrm
|
* @Date 2023-08-17 10:27:16
|
*/
|
@Controller
|
@RequestMapping("/sysJob")
|
public class SysJobController extends BaseController {
|
|
private String PREFIX = "modular/bs/sysJob";
|
|
@Autowired
|
private SysJobService sysJobService;
|
|
/**
|
* 跳转到主页面
|
*
|
* @author zrm
|
* @Date 2023-08-17
|
*/
|
@RequestMapping("")
|
public String index() {
|
return PREFIX + "/sysJob.html";
|
}
|
|
/**
|
* 新增页面
|
*
|
* @author zrm
|
* @Date 2023-08-17
|
*/
|
@RequestMapping("/add")
|
public String add() {
|
return PREFIX + "/sysJob_add.html";
|
}
|
|
/**
|
* 编辑页面
|
*
|
* @author zrm
|
* @Date 2023-08-17
|
*/
|
@RequestMapping("/edit")
|
public String edit() {
|
return PREFIX + "/sysJob_edit.html";
|
}
|
|
/**
|
* 新增接口
|
*
|
* @author zrm
|
* @Date 2023-08-17
|
*/
|
@RequestMapping("/addItem")
|
@ResponseBody
|
@DataSource(name = "self")
|
public ResponseData addItem(SysJobParam sysJobParam) {
|
this.sysJobService.add(sysJobParam);
|
SysJob sysJob = new SysJob();
|
BeanUtils.copyProperties(sysJobParam,sysJob);
|
QuartzUtil.insertOrUpdateJob(sysJob);
|
return ResponseData.success();
|
}
|
|
/**
|
* 编辑接口
|
*
|
* @author zrm
|
* @Date 2023-08-17
|
*/
|
@RequestMapping("/editItem")
|
@ResponseBody
|
@DataSource(name = "self")
|
public ResponseData editItem(SysJobParam sysJobParam) {
|
String inv = "";
|
if(sysJobParam.getInvokeTarget()!=null){
|
String invokeTarget = sysJobParam.getInvokeTarget();
|
if(invokeTarget.contains("40")){
|
inv = invokeTarget.replace("& #40;","(").replace("& #41;",")");
|
}
|
sysJobParam.setInvokeTarget(inv);
|
}
|
this.sysJobService.update(sysJobParam);
|
SysJob sysJob = new SysJob();
|
BeanUtils.copyProperties(sysJobParam,sysJob);
|
QuartzUtil.insertOrUpdateJob(sysJob);
|
return ResponseData.success();
|
}
|
|
/**
|
* 修改定时器状态
|
*
|
* @author zrm
|
* @Date 2023-08-17
|
*/
|
@RequestMapping("/editState")
|
@ResponseBody
|
@DataSource(name = "self")
|
public ResponseData editState(SysJobParam sysJobParam) {
|
SysJob sysJob = new SysJob();
|
BeanUtils.copyProperties(sysJobParam,sysJob);
|
this.sysJobService.saveOrUpdate(sysJob);
|
SysJob byId = sysJobService.getById(sysJobParam.getId());
|
QuartzUtil.insertOrUpdateJob(byId);
|
return ResponseData.success();
|
}
|
|
/**
|
* 删除接口
|
*
|
* @author zrm
|
* @Date 2023-08-17
|
*/
|
@RequestMapping("/delete")
|
@ResponseBody
|
@DataSource(name = "self")
|
public ResponseData delete(SysJobParam sysJobParam) {
|
this.sysJobService.delete(sysJobParam);
|
SysJob sysJob = new SysJob();
|
BeanUtils.copyProperties(sysJobParam,sysJob);
|
QuartzUtil.deleteJob(sysJob);
|
return ResponseData.success();
|
}
|
|
/**
|
* 查看详情接口
|
*
|
* @author zrm
|
* @Date 2023-08-17
|
*/
|
@RequestMapping("/detail")
|
@ResponseBody
|
@DataSource(name = "self")
|
public ResponseData detail(SysJobParam sysJobParam) {
|
SysJob detail = this.sysJobService.getById(sysJobParam.getId());
|
return ResponseData.success(detail);
|
}
|
|
/**
|
* 查询列表
|
*
|
* @author zrm
|
* @Date 2023-08-17
|
*/
|
@ResponseBody
|
@RequestMapping("/list")
|
@DataSource(name = "self")
|
public LayuiPageInfo list(SysJobParam sysJobParam) {
|
return this.sysJobService.findPageBySpec(sysJobParam);
|
}
|
|
}
|