dongyukun
8 天以前 0a2b23ad3f30dfb01c5d590fb98f39e93bfe1932
提交 | 用户 | 时间
9cfbab 1 package com.iailab.module.model.mcs.sche.controller.admin;
7fd198 2
3 import com.iailab.framework.common.pojo.CommonResult;
4 import com.iailab.framework.common.pojo.PageResult;
5 import com.iailab.framework.common.util.object.BeanUtils;
6eeac9 6 import com.iailab.module.model.api.mcs.dto.StScheduleModelOutDTO;
7fd198 7 import com.iailab.module.model.mcs.sche.entity.StScheduleModelEntity;
6eeac9 8 import com.iailab.module.model.mcs.sche.entity.StScheduleModelOutEntity;
408fbd 9 import com.iailab.module.model.mcs.sche.entity.StScheduleModelParamEntity;
10 import com.iailab.module.model.mcs.sche.entity.StScheduleModelSettingEntity;
6eeac9 11 import com.iailab.module.model.mcs.sche.service.StScheduleModelOutService;
408fbd 12 import com.iailab.module.model.mcs.sche.service.StScheduleModelParamService;
7fd198 13 import com.iailab.module.model.mcs.sche.service.StScheduleModelService;
408fbd 14 import com.iailab.module.model.mcs.sche.service.StScheduleModelSettingService;
15 import com.iailab.module.model.mcs.sche.vo.*;
bbc1ee 16 import io.swagger.v3.oas.annotations.Operation;
17 import io.swagger.v3.oas.annotations.tags.Tag;
7fd198 18 import org.springframework.beans.factory.annotation.Autowired;
bbc1ee 19 import org.springframework.security.access.prepost.PreAuthorize;
7fd198 20 import org.springframework.web.bind.annotation.*;
21
bbc1ee 22 import javax.validation.Valid;
7fd198 23
056470 24 import java.util.List;
25
7fd198 26 import static com.iailab.framework.common.pojo.CommonResult.error;
27 import static com.iailab.framework.common.pojo.CommonResult.success;
28
29 /**
30  * @author PanZhibao
31  * @date 2021年07月20日 14:35
32  */
bbc1ee 33 @Tag(name = "模型服务 - 调度模型管理")
7fd198 34 @RestController
bbc1ee 35 @RequestMapping("/model/sche/model")
7fd198 36 public class StScheduleModelController {
37
38     @Autowired
39     private StScheduleModelService stScheduleModelService;
40
408fbd 41     @Autowired
42     private StScheduleModelParamService stScheduleModelParamService;
43
44     @Autowired
45     private StScheduleModelSettingService stScheduleModelSettingService;
6eeac9 46     @Autowired
D 47     private StScheduleModelOutService stScheduleModelOutService;
408fbd 48
7fd198 49     @GetMapping("/page")
bbc1ee 50     @Operation(summary = "获得分页")
51     @PreAuthorize("@ss.hasPermission('sche:model:query')")
52     public CommonResult<PageResult<StScheduleModelRespVO>> page(@Valid StScheduleModelPageReqVO reqVO) {
53         PageResult<StScheduleModelEntity> page = stScheduleModelService.page(reqVO);
7fd198 54         return success(BeanUtils.toBean(page, StScheduleModelRespVO.class));
55     }
56
056470 57     @GetMapping("/list")
58     @PreAuthorize("@ss.hasPermission('sche:model:query')")
59     public CommonResult<List<StScheduleModelRespVO>> list() {
60         List<StScheduleModelEntity> list = stScheduleModelService.list();
61         return success(BeanUtils.toBean(list, StScheduleModelRespVO.class));
62     }
63
7fd198 64     @GetMapping("/get")
bbc1ee 65     @Operation(summary = "获得详情")
66     @PreAuthorize("@ss.hasPermission('sche:model:query')")
8b3ee3 67     public CommonResult<StScheduleModelRespVO> get(@RequestParam("id") String id) {
bbc1ee 68         StScheduleModelEntity data = stScheduleModelService.get(id);
408fbd 69         StScheduleModelRespVO result = BeanUtils.toBean(data, StScheduleModelRespVO.class);
70         List<StScheduleModelParamEntity> paramList = stScheduleModelParamService.getByModelId(data.getId());
71         result.setParamList(BeanUtils.toBean(paramList, StScheduleModelParamRespVO.class));
72         List<StScheduleModelSettingEntity> settingList = stScheduleModelSettingService.getByModelId(data.getId());
73         result.setSettingList(BeanUtils.toBean(settingList, StScheduleModelSettingRespVO.class));
6eeac9 74         List<StScheduleModelOutDTO> outList = stScheduleModelOutService.list(data.getId());
D 75         result.setModelOut(outList);
408fbd 76         return success(result);
7fd198 77     }
78
79     @PostMapping("/create")
bbc1ee 80     @Operation(summary = "创建模型")
81     @PreAuthorize("@ss.hasPermission('sche:model:create')")
8b3ee3 82     public CommonResult<Boolean> save(@Valid @RequestBody StScheduleModelSaveReqVO reqVO) {
bbc1ee 83         Long count = stScheduleModelService.check(reqVO);
7fd198 84         if (count > 0) {
85             return error(999, "名称或编号重复");
86         }
bbc1ee 87         stScheduleModelService.create(reqVO);
7fd198 88         return success(true);
89     }
90
91     @PutMapping("/update")
bbc1ee 92     @Operation(summary = "更新模型")
93     @PreAuthorize("@ss.hasPermission('sche:model:update')")
8b3ee3 94     public CommonResult<Boolean> update(@Valid @RequestBody StScheduleModelSaveReqVO reqVO) {
bbc1ee 95         Long count = stScheduleModelService.check(reqVO);
7fd198 96         if (count > 0) {
97             return error(999, "名称或编号重复");
98         }
bbc1ee 99         stScheduleModelService.update(reqVO);
7fd198 100         return success(true);
101     }
102
103     @DeleteMapping("/delete")
bbc1ee 104     @Operation(summary = "删除模型")
105     @PreAuthorize("@ss.hasPermission('sche:model:delete')")
8b3ee3 106     public CommonResult<Boolean> delete(@RequestParam("id") String id) {
bbc1ee 107         stScheduleModelService.delete(id);
7fd198 108         return success(true);
109     }
110 }