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