唐耀东
2022-10-12 d1bcbbefab4da603c275ed61d0018a46dbc67d1e
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
package com.ruoyi.web.controller.oa;
 
import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
 
import com.ruoyi.common.annotation.DataDictClass;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.oa.domain.vo.SgIotVo;
import com.ruoyi.oa.domain.bo.SgIotBo;
import com.ruoyi.oa.service.ISgIotService;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiOperation;
 
/**
 * IoT设备Controller
 *
 * @author ruoyi
 * @date 2022-05-12
 */
@Validated
@Api(value = "IoT设备控制器", tags = {"IoT设备管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/oa/iot")
public class SgIotController extends BaseController {
 
    private final ISgIotService iSgIotService;
 
    /**
     * 查询IoT设备列表
     */
    @DataDictClass
    @ApiOperation("查询IoT设备列表")
//    @PreAuthorize("@ss.hasPermi('oa:iot:list')")
    @GetMapping("/list")
    public TableDataInfo<SgIotVo> list(@Validated(QueryGroup.class) SgIotBo bo) {
        return iSgIotService.queryPageList(bo);
    }
 
    /**
     * 获取外设数量
     */
    @ApiOperation("查询IoT设备列表")
    @GetMapping("/number")
    public AjaxResult getNumber(SgIotBo bo) {
        return AjaxResult.success(iSgIotService.getNumber(bo));
    }
 
    /**
     * 导出IoT设备列表
     */
    @ApiOperation("导出IoT设备列表")
    @PreAuthorize("@ss.hasPermi('oa:iot:export')")
    @Log(title = "IoT设备", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public void export(@Validated SgIotBo bo, HttpServletResponse response) {
        List<SgIotVo> list = iSgIotService.queryList(bo);
        ExcelUtil.exportExcel(list, "IoT设备", SgIotVo.class, response);
    }
 
    /**
     * 获取IoT设备详细信息
     */
    @ApiOperation("获取IoT设备详细信息")
//    @PreAuthorize("@ss.hasPermi('oa:iot:query')")
    @GetMapping("/{id}")
    public AjaxResult<SgIotVo> getInfo(@ApiParam("主键")
                                                  @NotNull(message = "主键不能为空")
                                                  @PathVariable("id") Long id) {
        return AjaxResult.success(iSgIotService.queryById(id));
    }
 
    /**
     * 新增IoT设备
     */
    @ApiOperation("新增IoT设备")
//    @PreAuthorize("@ss.hasPermi('oa:iot:add')")
    @Log(title = "IoT设备", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody SgIotBo bo) {
        return toAjax(iSgIotService.insertByBo(bo) ? 1 : 0);
    }
 
    /**
     * 修改IoT设备
     */
    @ApiOperation("修改IoT设备")
//    @PreAuthorize("@ss.hasPermi('oa:iot:edit')")
    @Log(title = "IoT设备", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public AjaxResult<Void> edit(@Validated(EditGroup.class) @RequestBody SgIotBo bo) {
        return toAjax(iSgIotService.updateByBo(bo) ? 1 : 0);
    }
 
    /**
     * 删除IoT设备
     */
    @ApiOperation("删除IoT设备")
//    @PreAuthorize("@ss.hasPermi('oa:iot:remove')")
    @Log(title = "IoT设备" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@ApiParam("主键串")
                                       @NotEmpty(message = "主键不能为空")
                                       @PathVariable Long[] ids) {
        return toAjax(iSgIotService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }
}