liusheng
2025-05-09 6e34bc4a364b68ab0e62159eecc61bb6b0bf8201
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package com.ruoyi.web.controller.smartor;
 
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.smartor.domain.IvrLibaTarget;
import com.smartor.domain.IvrLibaTargetVO;
import com.smartor.service.IIvrLibaTargetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletResponse;
import java.util.List;
 
/**
 * 指标选项库Controller
 *
 * @author ruoyi
 * @date 2023-12-14
 */
@Api(description = "指标库")
@RestController
@RequestMapping("/smartor/target")
public class IvrLibaTargetController extends BaseController {
    @Autowired
    private IIvrLibaTargetService ivrLibaTargetService;
 
    /**
     * 查询指标选项库列表
     */
    @ApiOperation("查询指标列表")
    //@PreAuthorize("@ss.hasPermi('system:target:list')")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody IvrLibaTarget ivrLibaTarget) {
        PageUtils.startPageByPost(ivrLibaTarget.getPageNum(), ivrLibaTarget.getPageSize());
        List<IvrLibaTarget> list = ivrLibaTargetService.selectIvrLibaTargetList(ivrLibaTarget);
        return getDataTable(list);
    }
 
    /**
     * 导出指标列表
     */
    //@PreAuthorize("@ss.hasPermi('system:target:export')")
    @Log(title = "指标库", businessType = BusinessType.EXPORT)
    @ApiOperation("导出指标列表")
    @PostMapping("/export")
    public void export(HttpServletResponse response, IvrLibaTarget ivrLibaTarget) {
        List<IvrLibaTarget> list = ivrLibaTargetService.selectIvrLibaTargetList(ivrLibaTarget);
        ExcelUtil<IvrLibaTarget> util = new ExcelUtil<IvrLibaTarget>(IvrLibaTarget.class);
        util.exportExcel(response, list, "指标选项库数据");
    }
 
    /**
     * 获取指标信息通过id
     */
    @ApiOperation("获取指标信息通过id")
    //@PreAuthorize("@ss.hasPermi('system:target:query')")
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(ivrLibaTargetService.selectIvrLibaTargetByTargetID(id));
    }
 
    /**
     * 新增指标
     */
    //@PreAuthorize("@ss.hasPermi('system:target:add')")
    @Log(title = "指标选项库", businessType = BusinessType.INSERT)
    @ApiOperation("新增指标(这个接口没啥用了,用”新增或修改指标信息“这个接口好一些)")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody IvrLibaTargetVO ivrLibaTargetVO) {
        SysUser user = getLoginUser().getUser();
        ivrLibaTargetVO.setOrgid(user.getOrgid());
        return toAjax(ivrLibaTargetService.insertIvrLibaTarget(ivrLibaTargetVO));
    }
 
    /**
     * 新增或修改指标信息
     */
    @ApiOperation("新增或修改指标信息")
    @Log(title = "指标选项库", businessType = BusinessType.UPDATE)
    @PostMapping("/saveOrupdateIvrLibaTarget")
    public AjaxResult saveOrupdateIvrLibaTarget(@RequestBody IvrLibaTargetVO ivrLibaTargetVO) {
        SysUser user = getLoginUser().getUser();
        ivrLibaTargetVO.setOrgid(user.getOrgid());
        return toAjax(ivrLibaTargetService.saveOrupdateIvrLibaTarget(ivrLibaTargetVO));
    }
 
    /**
     * 删除指标
     */
    @ApiOperation("删除指标")
    //@PreAuthorize("@ss.hasPermi('system:target:remove')")
    @Log(title = "指标选项库", businessType = BusinessType.DELETE)
    @GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(ivrLibaTargetService.deleteIvrLibaTargetByTargetIDs(ids));
    }
 
    /**
     * 查询指标选项库列表
     */
    @ApiOperation("查询指标和关联的指标选项")
    //@PreAuthorize("@ss.hasPermi('system:target:list')")
    @PostMapping("/targetInfo")
    public TableDataInfo targetInfo(@RequestBody IvrLibaTarget ivrLibaTarget) {
        PageUtils.startPageByPost(ivrLibaTarget.getPageNum(), ivrLibaTarget.getPageSize());
        //这个用来获取分页数据
        List<IvrLibaTargetVO> ivrLibaTargetVOS = ivrLibaTargetService.targetInfo(ivrLibaTarget);
 
        //用于分页
        ivrLibaTarget.setPageNum(null);
        ivrLibaTarget.setPageSize(null);
        List<IvrLibaTarget> ivrLibaTargets = ivrLibaTargetService.selectIvrLibaTargetList(ivrLibaTarget);
        //分页
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setMsg("查询成功");
        rspData.setRows(ivrLibaTargetVOS);
        rspData.setTotal(new PageInfo(ivrLibaTargets).getTotal());
 
        return rspData;
    }
 
    /**
     * 指标测试问题匹配
     */
    @ApiOperation("指标测试问题匹配")
    @PostMapping("/targetQuesMate")
    public AjaxResult targetQuesMate(@RequestBody IvrLibaTargetVO ivrLibaTarget) {
        return success(ivrLibaTargetService.targetQuesMate(ivrLibaTarget));
    }
 
}