package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TDeviceSet;
import com.ruoyi.system.service.ITDeviceSetService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备设置Controller
 * 
 * @author zhengjie
 * @date 2023-09-20
 */
@RestController
@RequestMapping("/system/deviceset")
public class TDeviceSetController extends BaseController
{
    @Autowired
    private ITDeviceSetService tDeviceSetService;

    /**
     * 查询设备设置列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TDeviceSet tDeviceSet)
    {
        startPage();
        List<TDeviceSet> list = tDeviceSetService.selectTDeviceSetList(tDeviceSet);
        return getDataTable(list);
    }

    /**
     * 导出设备设置列表
     */
    @Log(title = "设备设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TDeviceSet tDeviceSet)
    {
        List<TDeviceSet> list = tDeviceSetService.selectTDeviceSetList(tDeviceSet);
        ExcelUtil<TDeviceSet> util = new ExcelUtil<TDeviceSet>(TDeviceSet.class);
        util.exportExcel(response, list, "设备设置数据");
    }

    /**
     * 获取设备设置详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(tDeviceSetService.selectTDeviceSetById(id));
    }

    /**
     * 新增设备设置
     */
    @Log(title = "设备设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDeviceSet tDeviceSet)
    {
        return toAjax(tDeviceSetService.insertTDeviceSet(tDeviceSet));
    }

    /**
     * 修改设备设置
     */
    @Log(title = "设备设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDeviceSet tDeviceSet)
    {
        return toAjax(tDeviceSetService.updateTDeviceSet(tDeviceSet));
    }

    /**
     * 删除设备设置
     */
    @Log(title = "设备设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(tDeviceSetService.deleteTDeviceSetByIds(ids));
    }
}
