package cn.gistack.job.executor.controller;
|
|
import cn.gistack.job.executor.entity.XxlJobInfo;
|
import cn.gistack.job.executor.service.IXxlJobInfoService;
|
import cn.gistack.job.executor.vo.XxlJobInfoVO;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.AllArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springblade.core.mp.support.Condition;
|
import org.springblade.core.mp.support.Query;
|
import org.springblade.core.tool.api.R;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.Arrays;
|
|
/**
|
* @author zhongrj
|
* @date 2023-05-22
|
*/
|
@Slf4j
|
@Api(tags="定时任务")
|
@RestController
|
@AllArgsConstructor
|
@RequestMapping("/xxl-job/xxl-job")
|
public class TaskXxlJobController {
|
|
private IXxlJobInfoService xxlJobInfoService;
|
|
@ApiOperation(value="定时任务-分页列表查询", notes="定时任务-分页列表查询")
|
@GetMapping(value = "/list")
|
public R list(XxlJobInfo xxlJobInfo, Query query) {
|
IPage<XxlJobInfo> pageList = xxlJobInfoService.page(Condition.getPage(query), Condition.getQueryWrapper(xxlJobInfo));
|
return R.data(pageList);
|
}
|
|
/**
|
* 自定义分页查询定时任务列表信息
|
* @param xxlJobInfo
|
* @param query
|
* @return
|
*/
|
@ApiOperation(value="定时任务-自定义分页查询定时任务列表信息", notes="定时任务-自定义分页查询定时任务列表信息")
|
@GetMapping(value = "/page")
|
public R selectXxlJobPage(XxlJobInfoVO xxlJobInfo, Query query) {
|
IPage<XxlJobInfoVO> pageList = xxlJobInfoService.selectXxlJobPage(Condition.getPage(query), xxlJobInfo);
|
return R.data(pageList);
|
}
|
|
/**
|
* 通过id查询
|
*
|
* @param id
|
* @return
|
*/
|
@ApiOperation(value = "定时任务-通过id查询", notes = "定时任务-通过id查询")
|
@GetMapping(value = "/queryById")
|
public R queryById(@RequestParam(name = "id", required = true) String id) {
|
XxlJobInfo xxlJobInfo = xxlJobInfoService.getById(id);
|
return R.data(xxlJobInfo);
|
}
|
|
/**
|
* 添加
|
*/
|
@ApiOperation(value="定时任务-添加", notes="定时任务-添加")
|
@PostMapping(value = "/add")
|
public R add(@RequestBody XxlJobInfo xxlJobInfo) {
|
return R.data(xxlJobInfoService.save(xxlJobInfo));
|
}
|
|
/**
|
* 添加-自定义
|
*/
|
@ApiOperation(value="定时任务-添加", notes="定时任务-添加")
|
@PostMapping(value = "/save")
|
public R save(@RequestBody XxlJobInfoVO xxlJobInfo) {
|
return R.data(xxlJobInfoService.saveXxlJob(xxlJobInfo));
|
}
|
|
/**
|
* 编辑
|
* @return
|
*/
|
@ApiOperation(value="定时任务-编辑", notes="定时任务-编辑")
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
public R edit(@RequestBody XxlJobInfo xxlJobInfo) {
|
return R.data(xxlJobInfoService.updateById(xxlJobInfo));
|
}
|
|
/**
|
* 编辑--自定义
|
* @return
|
*/
|
@ApiOperation(value="定时任务-编辑", notes="定时任务-编辑")
|
@RequestMapping(value = "/update", method = {RequestMethod.PUT,RequestMethod.POST})
|
public R update(@RequestBody XxlJobInfoVO xxlJobInfo) {
|
return R.data(xxlJobInfoService.updateXxlJobById(xxlJobInfo));
|
}
|
|
/**
|
* 通过id删除
|
*
|
* @param id
|
* @return
|
*/
|
@ApiOperation(value="定时任务-通过id删除", notes="定时任务-通过id删除")
|
@PostMapping(value = "/delete")
|
public R delete(@RequestParam(name="id",required=true) String id) {
|
return R.data(xxlJobInfoService.removeById(id));
|
}
|
|
/**
|
* 批量删除
|
*
|
* @param ids
|
* @return
|
*/
|
@ApiOperation(value="定时任务-批量删除", notes="定时任务-批量删除")
|
@PostMapping(value = "/deleteBatch")
|
public R deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
return R.data(xxlJobInfoService.removeByIds(Arrays.asList(ids.split(","))));
|
}
|
|
}
|