潘志宝
2024-09-23 0a2f6f78683ba1c4e07f1359c1e7bf105a4bd507
提交 | 用户 | 时间
c06f48 1 package com.iailab.module.model.mcs.pre.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.pre.entity.MmItemTypeEntity;
7 import com.iailab.module.model.mcs.pre.service.MmItemTypeService;
8 import com.iailab.module.model.mcs.pre.vo.MmItemTypePageReqVO;
9 import com.iailab.module.model.mcs.pre.vo.MmItemTypeRespVO;
10 import org.springframework.beans.factory.annotation.Autowired;
abba54 11 import org.springframework.security.access.prepost.PreAuthorize;
7fd198 12 import org.springframework.validation.annotation.Validated;
13 import org.springframework.web.bind.annotation.*;
14
15 import static com.iailab.framework.common.pojo.CommonResult.error;
16 import static com.iailab.framework.common.pojo.CommonResult.success;
17
18 /**
19  * @author PanZhibao
20  * @date 2021年04月22日 9:57
21  */
22 @RestController
abba54 23 @RequestMapping("/model/pre/item-type")
7fd198 24 public class MmItemTypeController {
25
26     @Autowired
27     private MmItemTypeService mmItemTypeService;
28
29     /**
30      * 预测项类型列表
31      */
32     @GetMapping("/page")
abba54 33     @PreAuthorize("@ss.hasPermission('model:pre-item:query')")
7fd198 34     public CommonResult<PageResult<MmItemTypeRespVO>> page(@Validated MmItemTypePageReqVO reqVO) {
35         PageResult<MmItemTypeEntity> page = mmItemTypeService.page(reqVO);
36
37         return success(BeanUtils.toBean(page, MmItemTypeRespVO.class));
38     }
39
40     /**
41      * 预测项类型信息
42      */
d395d2 43     @GetMapping("/get/{id}")
abba54 44     @PreAuthorize("@ss.hasPermission('model:pre-item:query')")
7fd198 45     public CommonResult<MmItemTypeEntity> info(@PathVariable("id") String id) {
46         MmItemTypeEntity itemType = mmItemTypeService.selectById(id);
47
48         return success(itemType);
49     }
50
51     /**
52      * 保存预测项类型
53      */
54     @PostMapping("/create")
abba54 55     @PreAuthorize("@ss.hasPermission('model:pre-item:create')")
7fd198 56     public CommonResult<Boolean> save(@RequestBody MmItemTypeEntity itemType) {
57         int count = mmItemTypeService.check(itemType);
58         if (count > 0) {
59             return error(999,"名称重复");
60         }
61         mmItemTypeService.saveItemType(itemType);
62         return success(true);
63     }
64
65     /**
66      * 修改预测项类型
67      */
68     @PutMapping("/update")
abba54 69     @PreAuthorize("@ss.hasPermission('model:pre-item:update')")
7fd198 70     public CommonResult<Boolean> update(@RequestBody MmItemTypeEntity itemType) {
71         int count = mmItemTypeService.check(itemType);
72         if (count > 0) {
73             return error(999,"名称重复");
74         }
75         mmItemTypeService.update(itemType);
76         return success(true);
77     }
78
79     /**
80      * 删除预测项类型
81      */
82     @DeleteMapping("/delete")
abba54 83     @PreAuthorize("@ss.hasPermission('model:pre-item:delete')")
7fd198 84     public CommonResult<Boolean> delete(@RequestParam("id") String id) {
85         mmItemTypeService.deleteBatch(new String[]{id});
86         return success(true);
87     }
88 }