定时任务swagger完善

This commit is contained in:
linfeng 2024-03-20 11:57:10 +08:00
parent 755226505e
commit 0a7905f893
2 changed files with 79 additions and 87 deletions

View File

@ -18,6 +18,7 @@ import io.linfeng.common.validator.ValidatorUtils;
import io.linfeng.modules.job.entity.ScheduleJobEntity;
import io.linfeng.modules.job.service.ScheduleJobService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -34,103 +35,97 @@ import java.util.Map;
public class ScheduleJobController {
@Autowired
private ScheduleJobService scheduleJobService;
/**
* 定时任务列表
*/
@RequestMapping("/list")
@GetMapping("/list")
@RequiresPermissions("sys:schedule:list")
@ApiOperation("定时任务列表")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = scheduleJobService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 定时任务信息
*/
@RequestMapping("/info/{jobId}")
@GetMapping("/info/{jobId}")
@RequiresPermissions("sys:schedule:info")
@ApiOperation("定时任务详情")
public R info(@PathVariable("jobId") Long jobId){
ScheduleJobEntity schedule = scheduleJobService.getById(jobId);
return R.ok().put("schedule", schedule);
}
/**
* 保存定时任务
*/
@SysLog("保存定时任务")
@RequestMapping("/save")
@PostMapping("/save")
@RequiresPermissions("sys:schedule:save")
@ApiOperation("保存定时任务")
public R save(@RequestBody ScheduleJobEntity scheduleJob){
ValidatorUtils.validateEntity(scheduleJob);
scheduleJobService.saveJob(scheduleJob);
return R.ok();
}
/**
* 修改定时任务
*/
@SysLog("修改定时任务")
@RequestMapping("/update")
@RequiresPermissions("sys:schedule:update")
public R update(@RequestBody ScheduleJobEntity scheduleJob){
ValidatorUtils.validateEntity(scheduleJob);
scheduleJobService.update(scheduleJob);
return R.ok();
}
/**
* 删除定时任务
*/
@SysLog("删除定时任务")
@RequestMapping("/delete")
@RequiresPermissions("sys:schedule:delete")
public R delete(@RequestBody Long[] jobIds){
scheduleJobService.deleteBatch(jobIds);
return R.ok();
}
/**
* 立即执行任务
*/
@SysLog("立即执行任务")
@RequestMapping("/run")
@RequiresPermissions("sys:schedule:run")
public R run(@RequestBody Long[] jobIds){
scheduleJobService.run(jobIds);
return R.ok();
}
/**
* 暂停定时任务
*/
@SysLog("暂停定时任务")
@RequestMapping("/pause")
@RequiresPermissions("sys:schedule:pause")
public R pause(@RequestBody Long[] jobIds){
scheduleJobService.pause(jobIds);
return R.ok();
}
/**
* 恢复定时任务
*/
@SysLog("恢复定时任务")
@RequestMapping("/resume")
@RequiresPermissions("sys:schedule:resume")
public R resume(@RequestBody Long[] jobIds){
scheduleJobService.resume(jobIds);
return R.ok();
}
}
@SysLog("修改定时任务")
@PostMapping("/update")
@RequiresPermissions("sys:schedule:update")
@ApiOperation("修改定时任务")
public R update(@RequestBody ScheduleJobEntity scheduleJob){
ValidatorUtils.validateEntity(scheduleJob);
scheduleJobService.update(scheduleJob);
return R.ok();
}
@SysLog("删除定时任务")
@PostMapping("/delete")
@RequiresPermissions("sys:schedule:delete")
@ApiOperation("删除定时任务")
public R delete(@RequestBody Long[] jobIds){
scheduleJobService.deleteBatch(jobIds);
return R.ok();
}
@SysLog("立即执行任务")
@PostMapping("/run")
@RequiresPermissions("sys:schedule:run")
@ApiOperation("删除定时任务")
public R run(@RequestBody Long[] jobIds){
scheduleJobService.run(jobIds);
return R.ok();
}
@SysLog("暂停定时任务")
@PostMapping("/pause")
@RequiresPermissions("sys:schedule:pause")
@ApiOperation("暂停定时任务")
public R pause(@RequestBody Long[] jobIds){
scheduleJobService.pause(jobIds);
return R.ok();
}
@SysLog("恢复定时任务")
@PostMapping("/resume")
@RequiresPermissions("sys:schedule:resume")
@ApiOperation("恢复定时任务")
public R resume(@RequestBody Long[] jobIds){
scheduleJobService.resume(jobIds);
return R.ok();
}
}

View File

@ -18,10 +18,7 @@ import io.linfeng.modules.job.service.ScheduleJobLogService;
import io.swagger.annotations.Api;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@ -39,7 +36,7 @@ public class ScheduleJobLogController {
/**
* 定时任务日志列表
*/
@RequestMapping("/list")
@GetMapping("/list")
@RequiresPermissions("sys:schedule:log")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = scheduleJobLogService.queryPage(params);
@ -50,7 +47,7 @@ public class ScheduleJobLogController {
/**
* 定时任务日志信息
*/
@RequestMapping("/info/{logId}")
@GetMapping("/info/{logId}")
public R info(@PathVariable("logId") Long logId){
ScheduleJobLogEntity log = scheduleJobLogService.getById(logId);