TDeviceInfoController.java 4.12 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.domain.entity.SysDept;
7
import com.zehong.common.core.page.TableDataInfo;
8
import com.zehong.common.enums.BusinessType;
9
import com.zehong.common.utils.poi.ExcelUtil;
10 11
import com.zehong.system.domain.TDeviceInfo;
import com.zehong.system.service.ITDeviceInfoService;
12 13 14 15 16 17
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;
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

/**
 * 设备信息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);
    }

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

54 55 56 57 58 59 60 61 62
    /**
     * 获取设备下拉树列表
     */
    @PutMapping("/deviceTree")
    public AjaxResult deviceTree(@RequestBody List<TDeviceInfo> deviceInfoList)
    {
        return AjaxResult.success(tDeviceInfoService.buildDeviceTreeSelect(deviceInfoList));
    }

63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
    /**
     * 导出设备信息列表
     */
    @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}")
81
    public AjaxResult getInfo(@PathVariable("deviceId") int deviceId)
82 83 84 85 86 87 88 89 90 91 92 93
    {
        return AjaxResult.success(tDeviceInfoService.selectTDeviceInfoById(deviceId));
    }

    /**
     * 新增设备信息
     */
    @PreAuthorize("@ss.hasPermi('device:deviceInfo:add')")
    @Log(title = "设备信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDeviceInfo tDeviceInfo)
    {
94 95 96 97 98
        int result = tDeviceInfoService.insertTDeviceInfo(tDeviceInfo);
        if(result<=0){
            new Exception("设备信息插入失败");
        }
        return AjaxResult.success(tDeviceInfo.getDeviceId());
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
    }

    /**
     * 修改设备信息
     */
    @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}")
118
    public AjaxResult remove(@PathVariable int[] deviceIds)
119 120 121
    {
        return toAjax(tDeviceInfoService.deleteTDeviceInfoByIds(deviceIds));
    }
122 123 124 125 126 127 128 129 130 131 132

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