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