package com.iailab.module.shasteel.job.controller.admin; import com.iailab.framework.common.page.PageData; import com.iailab.framework.common.pojo.CommonResult; import com.iailab.module.shasteel.job.dto.ScheduleJobDTO; import com.iailab.module.shasteel.job.service.ScheduleJobService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import java.util.Map; import static com.iailab.framework.common.pojo.CommonResult.success; /** * 定时任务 * * @author Mark sunlightcs@gmail.com */ @RestController @RequestMapping("/shasteel/job/schedule") public class ScheduleJobController { @Autowired private ScheduleJobService scheduleJobService; @GetMapping("page") @PreAuthorize("@ss.hasPermission('shasteel:job:query')") public CommonResult> page(@RequestParam Map params){ PageData page = scheduleJobService.page(params); return success(page); } @GetMapping("{id}") @PreAuthorize("@ss.hasPermission('shasteel:job:query')") public CommonResult info(@PathVariable("id") Long id){ ScheduleJobDTO schedule = scheduleJobService.get(id); return success(schedule); } @PostMapping @PreAuthorize("@ss.hasPermission('shasteel:job:create')") public CommonResult save(@RequestBody ScheduleJobDTO dto){ scheduleJobService.save(dto); return success(); } @PutMapping @PreAuthorize("@ss.hasPermission('shasteel:job:update')") public CommonResult update(@RequestBody ScheduleJobDTO dto){ scheduleJobService.update(dto); return success(); } @DeleteMapping @PreAuthorize("@ss.hasPermission('shasteel:job:delete')") public CommonResult delete(@RequestParam Long id){ scheduleJobService.deleteById(id); return success(); } @PutMapping("/run") public CommonResult run(@RequestParam("id") Long id){ scheduleJobService.run(id); return success(); } @PutMapping("/pause") public CommonResult pause(@RequestParam("id") Long id){ Long[] ids = new Long[1]; ids[0] = id; scheduleJobService.pause(ids); return success(); } @PutMapping("/resume") public CommonResult resume(@RequestParam("id") Long id){ Long[] ids = new Long[1]; ids[0] = id; scheduleJobService.resume(ids); return success(); } }