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