沙钢智慧能源系统后端代码
liriming
2024-12-02 a63c400ff367e3cec30db6425a142d67dbaf158d
提交 | 用户 | 时间
516ef4 1 package com.iailab.module.shasteel.job.controller.admin;
L 2
94c44e 3 import com.iailab.framework.common.page.PageData;
516ef4 4 import com.iailab.framework.common.pojo.CommonResult;
L 5 import com.iailab.module.shasteel.job.dto.ScheduleJobDTO;
6 import com.iailab.module.shasteel.job.service.ScheduleJobService;
94c44e 7 import org.springframework.beans.factory.annotation.Autowired;
516ef4 8 import org.springframework.security.access.prepost.PreAuthorize;
L 9 import org.springframework.web.bind.annotation.*;
10
94c44e 11 import java.util.Map;
516ef4 12
L 13 import static com.iailab.framework.common.pojo.CommonResult.success;
14
15 /**
16  * 定时任务
17  *
18  * @author Mark sunlightcs@gmail.com
19  */
20 @RestController
ccf754 21 @RequestMapping("/shasteel/job/schedule")
516ef4 22 public class ScheduleJobController {
94c44e 23     @Autowired
516ef4 24     private ScheduleJobService scheduleJobService;
L 25
26     @GetMapping("page")
94c44e 27     @PreAuthorize("@ss.hasPermission('shasteel:job:query')")
D 28     public CommonResult<PageData<ScheduleJobDTO>> page(@RequestParam Map<String, Object> params){
29         PageData<ScheduleJobDTO> page = scheduleJobService.page(params);
516ef4 30
94c44e 31         return success(page);
516ef4 32     }
L 33
94c44e 34     @GetMapping("{id}")
D 35     @PreAuthorize("@ss.hasPermission('shasteel:job:query')")
36     public CommonResult<ScheduleJobDTO> info(@PathVariable("id") Long id){
516ef4 37         ScheduleJobDTO schedule = scheduleJobService.get(id);
L 38         
94c44e 39         return success(schedule);
516ef4 40     }
L 41
94c44e 42     @PostMapping
D 43     @PreAuthorize("@ss.hasPermission('shasteel:job:create')")
516ef4 44     public CommonResult save(@RequestBody ScheduleJobDTO dto){
L 45         scheduleJobService.save(dto);
46         
94c44e 47         return success();
516ef4 48     }
L 49
94c44e 50     @PutMapping
D 51     @PreAuthorize("@ss.hasPermission('shasteel:job:update')")
516ef4 52     public CommonResult update(@RequestBody ScheduleJobDTO dto){
L 53         scheduleJobService.update(dto);
54         
94c44e 55         return success();
516ef4 56     }
L 57
94c44e 58     @DeleteMapping
D 59     @PreAuthorize("@ss.hasPermission('shasteel:job:delete')")
60     public CommonResult delete(@RequestParam Long id){
61         scheduleJobService.deleteById(id);
62
63         return success();
516ef4 64     }
L 65
66     @PutMapping("/run")
67     public CommonResult run(@RequestParam("id") Long id){
94c44e 68         scheduleJobService.run(id);
516ef4 69         
94c44e 70         return success();
516ef4 71     }
L 72
73     @PutMapping("/pause")
74     public CommonResult pause(@RequestParam("id") Long id){
75         Long[] ids = new Long[1];
76         ids[0] = id;
77         scheduleJobService.pause(ids);
78         
94c44e 79         return success();
516ef4 80     }
L 81
82     @PutMapping("/resume")
83     public CommonResult resume(@RequestParam("id") Long id){
84         Long[] ids = new Long[1];
85         ids[0] = id;
86         scheduleJobService.resume(ids);
87         
94c44e 88         return success();
516ef4 89     }
L 90
91 }