沙钢智慧能源系统后端代码
liriming
2024-12-02 a63c400ff367e3cec30db6425a142d67dbaf158d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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<PageData<ScheduleJobDTO>> page(@RequestParam Map<String, Object> params){
        PageData<ScheduleJobDTO> page = scheduleJobService.page(params);
 
        return success(page);
    }
 
    @GetMapping("{id}")
    @PreAuthorize("@ss.hasPermission('shasteel:job:query')")
    public CommonResult<ScheduleJobDTO> 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();
    }
 
}