dongyukun
8 天以前 6eeac9efdb16f92d19536bf23a2d1471705fe752
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package com.iailab.module.model.mcs.sche.controller.admin;
 
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.module.model.api.mcs.dto.StScheduleModelOutDTO;
import com.iailab.module.model.mcs.sche.entity.StScheduleModelEntity;
import com.iailab.module.model.mcs.sche.entity.StScheduleModelOutEntity;
import com.iailab.module.model.mcs.sche.entity.StScheduleModelParamEntity;
import com.iailab.module.model.mcs.sche.entity.StScheduleModelSettingEntity;
import com.iailab.module.model.mcs.sche.service.StScheduleModelOutService;
import com.iailab.module.model.mcs.sche.service.StScheduleModelParamService;
import com.iailab.module.model.mcs.sche.service.StScheduleModelService;
import com.iailab.module.model.mcs.sche.service.StScheduleModelSettingService;
import com.iailab.module.model.mcs.sche.vo.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.Valid;
 
import java.util.List;
 
import static com.iailab.framework.common.pojo.CommonResult.error;
import static com.iailab.framework.common.pojo.CommonResult.success;
 
/**
 * @author PanZhibao
 * @date 2021年07月20日 14:35
 */
@Tag(name = "模型服务 - 调度模型管理")
@RestController
@RequestMapping("/model/sche/model")
public class StScheduleModelController {
 
    @Autowired
    private StScheduleModelService stScheduleModelService;
 
    @Autowired
    private StScheduleModelParamService stScheduleModelParamService;
 
    @Autowired
    private StScheduleModelSettingService stScheduleModelSettingService;
    @Autowired
    private StScheduleModelOutService stScheduleModelOutService;
 
    @GetMapping("/page")
    @Operation(summary = "获得分页")
    @PreAuthorize("@ss.hasPermission('sche:model:query')")
    public CommonResult<PageResult<StScheduleModelRespVO>> page(@Valid StScheduleModelPageReqVO reqVO) {
        PageResult<StScheduleModelEntity> page = stScheduleModelService.page(reqVO);
        return success(BeanUtils.toBean(page, StScheduleModelRespVO.class));
    }
 
    @GetMapping("/list")
    @PreAuthorize("@ss.hasPermission('sche:model:query')")
    public CommonResult<List<StScheduleModelRespVO>> list() {
        List<StScheduleModelEntity> list = stScheduleModelService.list();
        return success(BeanUtils.toBean(list, StScheduleModelRespVO.class));
    }
 
    @GetMapping("/get")
    @Operation(summary = "获得详情")
    @PreAuthorize("@ss.hasPermission('sche:model:query')")
    public CommonResult<StScheduleModelRespVO> get(@RequestParam("id") String id) {
        StScheduleModelEntity data = stScheduleModelService.get(id);
        StScheduleModelRespVO result = BeanUtils.toBean(data, StScheduleModelRespVO.class);
        List<StScheduleModelParamEntity> paramList = stScheduleModelParamService.getByModelId(data.getId());
        result.setParamList(BeanUtils.toBean(paramList, StScheduleModelParamRespVO.class));
        List<StScheduleModelSettingEntity> settingList = stScheduleModelSettingService.getByModelId(data.getId());
        result.setSettingList(BeanUtils.toBean(settingList, StScheduleModelSettingRespVO.class));
        List<StScheduleModelOutDTO> outList = stScheduleModelOutService.list(data.getId());
        result.setModelOut(outList);
        return success(result);
    }
 
    @PostMapping("/create")
    @Operation(summary = "创建模型")
    @PreAuthorize("@ss.hasPermission('sche:model:create')")
    public CommonResult<Boolean> save(@Valid @RequestBody StScheduleModelSaveReqVO reqVO) {
        Long count = stScheduleModelService.check(reqVO);
        if (count > 0) {
            return error(999, "名称或编号重复");
        }
        stScheduleModelService.create(reqVO);
        return success(true);
    }
 
    @PutMapping("/update")
    @Operation(summary = "更新模型")
    @PreAuthorize("@ss.hasPermission('sche:model:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody StScheduleModelSaveReqVO reqVO) {
        Long count = stScheduleModelService.check(reqVO);
        if (count > 0) {
            return error(999, "名称或编号重复");
        }
        stScheduleModelService.update(reqVO);
        return success(true);
    }
 
    @DeleteMapping("/delete")
    @Operation(summary = "删除模型")
    @PreAuthorize("@ss.hasPermission('sche:model:delete')")
    public CommonResult<Boolean> delete(@RequestParam("id") String id) {
        stScheduleModelService.delete(id);
        return success(true);
    }
}