潘志宝
2024-09-06 c06f48bded461209f117167fbf89ed57a3f37ef4
提交 | 用户 | 时间
7fd198 1 package com.iailab.module.model.mcs.sche.controller;
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.framework.common.util.object.ConvertUtils;
7 import com.iailab.module.model.mcs.sche.dto.StScheduleModelDto;
8 import com.iailab.module.model.mcs.sche.entity.StScheduleModelEntity;
9 import com.iailab.module.model.mcs.sche.service.StScheduleModelService;
10 import com.iailab.module.model.mcs.sche.vo.StScheduleModelRespVO;
11 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.web.bind.annotation.*;
13
14 import java.util.Map;
15
16 import static com.iailab.framework.common.pojo.CommonResult.error;
17 import static com.iailab.framework.common.pojo.CommonResult.success;
18
19 /**
20  * @author PanZhibao
21  * @date 2021年07月20日 14:35
22  */
23 @RestController
24 @RequestMapping("/sche/schedule-model")
25 public class StScheduleModelController {
26
27     @Autowired
28     private StScheduleModelService stScheduleModelService;
29
30     /**
31      * 调度模型类型列表
32      */
33     @GetMapping("/page")
34     public CommonResult<PageResult<StScheduleModelRespVO>> page(@RequestParam Map<String, Object> params) {
35         PageResult<StScheduleModelRespVO> page = stScheduleModelService.getPageList(params);
36
37         return success(BeanUtils.toBean(page, StScheduleModelRespVO.class));
38     }
39
40     /**
41      * 调度模型类型信息
42      */
43     @GetMapping("/get")
44     public CommonResult<StScheduleModelDto> info(@RequestParam("id") String id){
45         StScheduleModelDto scheduleMode = stScheduleModelService.getDetailById(id);
46         return success(scheduleMode);
47     }
48
49     /**
50      * 保存调度模型类型
51      */
52     @PostMapping("/create")
53     public CommonResult<Boolean> save(@RequestBody StScheduleModelDto scheduleMode){
54         StScheduleModelEntity stScheduleModelEntity = ConvertUtils.sourceToTarget(scheduleMode, StScheduleModelEntity.class);
55         int count = stScheduleModelService.check(stScheduleModelEntity);
56         if (count > 0) {
57             return error(999, "名称或编号重复");
58         }
59         stScheduleModelService.saveStScheduleModel(scheduleMode);
60         return success(true);
61     }
62
63     /**
64      * 修改调度模型类型
65      */
66     @PutMapping("/update")
67     public CommonResult<Boolean> update(@RequestBody StScheduleModelDto scheduleMode){
68         StScheduleModelEntity stScheduleModelEntity = ConvertUtils.sourceToTarget(scheduleMode, StScheduleModelEntity.class);
69         int count = stScheduleModelService.check(stScheduleModelEntity);
70         if (count > 0) {
71             return error(999, "名称或编号重复");
72         }
73         stScheduleModelService.update(scheduleMode);
74         return success(true);
75     }
76
77     /**
78      * 删除调度模型类型
79      */
80     @DeleteMapping("/delete")
81     public CommonResult<Boolean> delete(@RequestParam("id") String id){
82         stScheduleModelService.deleteBatch(new String[]{id});
83         return success(true);
84     }
85 }