疯狂的狮子li
2020-02-14 83c427c1bbf5e8e9a07bdea946479b005da0297e
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
package com.ruoyi.project.cstest.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 
import java.util.List;
import java.util.Arrays;
 
import com.ruoyi.common.utils.StringUtils;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.cstest.domain.CsTest;
import com.ruoyi.project.cstest.service.ICsTestService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;
 
/**
 * 测试Controller
 *
 * @author Lion Li
 * @date 2020-02-14
 */
@AllArgsConstructor
@RestController
@RequestMapping("/cstest/cstest" )
public class CsTestController extends BaseController {
 
    private final ICsTestService iCsTestService;
 
    /**
     * 查询测试列表
     */
    @PreAuthorize("@ss.hasPermi('cstest:cstest:list')" )
    @GetMapping("/list" )
    public TableDataInfo list(CsTest csTest) {
        startPage();
        LambdaQueryWrapper<CsTest> lqw = new LambdaQueryWrapper<CsTest>();
        if (StringUtils.isNotBlank(csTest.getTestKey())){
            lqw.like(CsTest::getTestKey ,csTest.getTestKey());
        }
        if (StringUtils.isNotBlank(csTest.getValue())){
            lqw.like(CsTest::getValue ,csTest.getValue());
        }
        if (csTest.getCreateTime() != null){
            lqw.eq(CsTest::getCreateTime ,csTest.getCreateTime());
        }
        List<CsTest> list = iCsTestService.list(lqw);
        return getDataTable(list);
    }
 
    /**
     * 导出测试列表
     */
    @PreAuthorize("@ss.hasPermi('cstest:cstest:export')" )
    @Log(title = "测试" , businessType = BusinessType.EXPORT)
    @GetMapping("/export" )
    public AjaxResult export(CsTest csTest) {
        LambdaQueryWrapper<CsTest> lqw = new LambdaQueryWrapper<CsTest>(csTest);
        List<CsTest> list = iCsTestService.list(lqw);
        ExcelUtil<CsTest> util = new ExcelUtil<CsTest>(CsTest. class);
        return util.exportExcel(list, "cstest" );
    }
 
    /**
     * 获取测试详细信息
     */
    @PreAuthorize("@ss.hasPermi('cstest:cstest:query')" )
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) Integer id) {
        return AjaxResult.success(iCsTestService.getById(id));
    }
 
    /**
     * 新增测试
     */
    @PreAuthorize("@ss.hasPermi('cstest:cstest:add')" )
    @Log(title = "测试" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsTest csTest) {
        return toAjax(iCsTestService.save(csTest) ? 1 : 0);
    }
 
    /**
     * 修改测试
     */
    @PreAuthorize("@ss.hasPermi('cstest:cstest:edit')" )
    @Log(title = "测试" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsTest csTest) {
        return toAjax(iCsTestService.updateById(csTest) ? 1 : 0);
    }
 
    /**
     * 删除测试
     */
    @PreAuthorize("@ss.hasPermi('cstest:cstest:remove')" )
    @Log(title = "测试" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(iCsTestService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
    }
}