package com.ruoyi.business.controller;

import java.util.List;
import java.io.IOException;
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.HwSceneMode;
import com.ruoyi.business.service.IHwSceneModeService;
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("/sceneMode")
public class HwSceneModeController extends BaseController
{
    @Autowired
    private IHwSceneModeService hwSceneModeService;

    /**
     * 查询场景类型列表
     */
    @RequiresPermissions("business:sceneMode:list")
    @GetMapping("/list")
    public TableDataInfo list(HwSceneMode hwSceneMode)
    {
        startPage();
        List<HwSceneMode> list = hwSceneModeService.selectHwSceneModeList(hwSceneMode);
        return getDataTable(list);
    }

    /**
     * 导出场景类型列表
     */
    @RequiresPermissions("business:sceneMode:export")
    @Log(title = "场景类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HwSceneMode hwSceneMode)
    {
        List<HwSceneMode> list = hwSceneModeService.selectHwSceneModeList(hwSceneMode);
        ExcelUtil<HwSceneMode> util = new ExcelUtil<HwSceneMode>(HwSceneMode.class);
        util.exportExcel(response, list, "场景类型数据");
    }

    /**
     * 获取场景类型详细信息
     */
    @RequiresPermissions("business:sceneMode:query")
    @GetMapping(value = "/{sceneModeId}")
    public AjaxResult getInfo(@PathVariable("sceneModeId") Long sceneModeId)
    {
        return success(hwSceneModeService.selectHwSceneModeBySceneModeId(sceneModeId));
    }

    /**
     * 新增场景类型
     */
    @RequiresPermissions("business:sceneMode:add")
    @Log(title = "场景类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HwSceneMode hwSceneMode)
    {
        return toAjax(hwSceneModeService.insertHwSceneMode(hwSceneMode));
    }

    /**
     * 修改场景类型
     */
    @RequiresPermissions("business:sceneMode:edit")
    @Log(title = "场景类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HwSceneMode hwSceneMode)
    {
        return toAjax(hwSceneModeService.updateHwSceneMode(hwSceneMode));
    }

    /**
     * 删除场景类型
     */
    @RequiresPermissions("business:sceneMode:remove")
    @Log(title = "场景类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sceneModeIds}")
    public AjaxResult remove(@PathVariable Long[] sceneModeIds)
    {
        return toAjax(hwSceneModeService.deleteHwSceneModeBySceneModeIds(sceneModeIds));
    }
}
