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