TDeviceInfoController.java 3.81 KB
Newer Older
1 2 3 4 5
package com.zehong.web.controller.device;

import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
6
import com.zehong.common.core.page.TableDataInfo;
7
import com.zehong.common.enums.BusinessType;
8
import com.zehong.common.utils.poi.ExcelUtil;
9 10
import com.zehong.system.domain.TDeviceInfo;
import com.zehong.system.service.ITDeviceInfoService;
11 12 13 14 15 16
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
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

/**
 * 设备信息Controller
 * 
 * @author zehong
 * @date 2021-07-09
 */
@RestController
@RequestMapping("/device/deviceInfo")
public class TDeviceInfoController extends BaseController
{
    @Autowired
    private ITDeviceInfoService tDeviceInfoService;

    /**
     * 查询设备信息列表
     */
    @PreAuthorize("@ss.hasPermi('device:deviceInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(TDeviceInfo tDeviceInfo)
    {
        startPage();
        List<TDeviceInfo> list = tDeviceInfoService.selectTDeviceInfoList(tDeviceInfo);
        return getDataTable(list);
    }

43 44 45 46 47 48 49 50 51 52
    /**
     * 获取所有设备信息
     * @param tDeviceInfo
     * @return
     */
    @GetMapping("/deviceListInfo")
    public AjaxResult deviceListInfo(TDeviceInfo tDeviceInfo){
        return AjaxResult.success(tDeviceInfoService.selectTDeviceInfoList(tDeviceInfo));
    }

53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
    /**
     * 导出设备信息列表
     */
    @PreAuthorize("@ss.hasPermi('device:deviceInfo:export')")
    @Log(title = "设备信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TDeviceInfo tDeviceInfo)
    {
        List<TDeviceInfo> list = tDeviceInfoService.selectTDeviceInfoList(tDeviceInfo);
        ExcelUtil<TDeviceInfo> util = new ExcelUtil<TDeviceInfo>(TDeviceInfo.class);
        return util.exportExcel(list, "设备信息数据");
    }

    /**
     * 获取设备信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('device:deviceInfo:query')")
    @GetMapping(value = "/{deviceId}")
71
    public AjaxResult getInfo(@PathVariable("deviceId") int deviceId)
72 73 74 75 76 77 78 79 80 81 82 83
    {
        return AjaxResult.success(tDeviceInfoService.selectTDeviceInfoById(deviceId));
    }

    /**
     * 新增设备信息
     */
    @PreAuthorize("@ss.hasPermi('device:deviceInfo:add')")
    @Log(title = "设备信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDeviceInfo tDeviceInfo)
    {
84 85 86 87 88
        int result = tDeviceInfoService.insertTDeviceInfo(tDeviceInfo);
        if(result<=0){
            new Exception("设备信息插入失败");
        }
        return AjaxResult.success(tDeviceInfo.getDeviceId());
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
    }

    /**
     * 修改设备信息
     */
    @PreAuthorize("@ss.hasPermi('device:deviceInfo:edit')")
    @Log(title = "设备信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDeviceInfo tDeviceInfo)
    {
        return toAjax(tDeviceInfoService.updateTDeviceInfo(tDeviceInfo));
    }

    /**
     * 删除设备信息
     */
    @PreAuthorize("@ss.hasPermi('device:deviceInfo:remove')")
    @Log(title = "设备信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deviceIds}")
108
    public AjaxResult remove(@PathVariable int[] deviceIds)
109 110 111
    {
        return toAjax(tDeviceInfoService.deleteTDeviceInfoByIds(deviceIds));
    }
112 113 114 115 116 117 118 119 120 121 122

    /**
     * 统计各设备类型的设备总数
     */
    @PreAuthorize("@ss.hasPermi('device:deviceInfo:countDeviceByType')")
    @GetMapping("/countDeviceByType")
    public AjaxResult countDeviceByType()
    {
        List<Map<Object, Object>> list = tDeviceInfoService.countDeviceByType();
        return AjaxResult.success(list);
    }
123
}