package com.ruoyi.business.controller;

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.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.business.domain.HwMonitorUnitType;
import com.ruoyi.business.service.IHwMonitorUnitTypeService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 监控单元类型Controller
 *
 * @author YINQ
 * @date 2023-08-31
 */
@RestController
@RequestMapping("/monitorUnitType")
public class HwMonitorUnitTypeController extends BaseController
{
    @Autowired
    private IHwMonitorUnitTypeService hwMonitorUnitTypeService;

    /**
     * 查询监控单元类型列表
     */
    @RequiresPermissions("business:monitorUnitType:list")
    @GetMapping("/list")
    public TableDataInfo list(HwMonitorUnitType hwMonitorUnitType)
    {
        startPage();
        List<HwMonitorUnitType> list = hwMonitorUnitTypeService.selectHwMonitorUnitTypeList(hwMonitorUnitType);
        return getDataTable(list);
    }


    /**
     * 导出监控单元类型列表
     */
    @RequiresPermissions("business:monitorUnitType:export")
    @Log(title = "监控单元类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HwMonitorUnitType hwMonitorUnitType)
    {
        List<HwMonitorUnitType> list = hwMonitorUnitTypeService.selectHwMonitorUnitTypeList(hwMonitorUnitType);
        ExcelUtil<HwMonitorUnitType> util = new ExcelUtil<HwMonitorUnitType>(HwMonitorUnitType.class);
        util.exportExcel(response, list, "监控单元类型数据");
    }

    /**
     * 获取监控单元类型详细信息
     */
    @RequiresPermissions("business:monitorUnitType:query")
    @GetMapping(value = "/{monitorUnitTypeId}")
    public AjaxResult getInfo(@PathVariable("monitorUnitTypeId") Long monitorUnitTypeId)
    {
        return success(hwMonitorUnitTypeService.selectHwMonitorUnitTypeByMonitorUnitTypeId(monitorUnitTypeId));
    }

    /**
     * 新增监控单元类型
     */
    @RequiresPermissions("business:monitorUnitType:add")
    @Log(title = "监控单元类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HwMonitorUnitType hwMonitorUnitType)
    {
        return toAjax(hwMonitorUnitTypeService.insertHwMonitorUnitType(hwMonitorUnitType));
    }

    /**
     * 修改监控单元类型
     */
    @RequiresPermissions("business:monitorUnitType:edit")
    @Log(title = "监控单元类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HwMonitorUnitType hwMonitorUnitType)
    {
        return toAjax(hwMonitorUnitTypeService.updateHwMonitorUnitType(hwMonitorUnitType));
    }

    /**
     * 删除监控单元类型
     */
    @RequiresPermissions("business:monitorUnitType:remove")
    @Log(title = "监控单元类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{monitorUnitTypeIds}")
    public AjaxResult remove(@PathVariable Long[] monitorUnitTypeIds)
    {
        return toAjax(hwMonitorUnitTypeService.deleteHwMonitorUnitTypeByMonitorUnitTypeIds(monitorUnitTypeIds));
    }
}
