package com.dcs.hnyz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.dcs.hnyz.domain.vo.ScreenSettingsFormVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
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.dcs.common.annotation.Log;
import com.dcs.common.core.controller.BaseController;
import com.dcs.common.core.domain.AjaxResult;
import com.dcs.common.enums.BusinessType;
import com.dcs.hnyz.domain.ScreenSettings;
import com.dcs.hnyz.service.IScreenSettingsService;
import com.dcs.common.utils.poi.ExcelUtil;
import com.dcs.common.core.page.TableDataInfo;

/**
 * 大屏设置管理Controller
 * 
 * @author hmy
 * @date 2025-04-30
 */
@Api(tags = "大屏设置管理")
@RestController
@RequestMapping("/hnyz/screenSettings")
public class ScreenSettingsController extends BaseController
{
    @Autowired
    private IScreenSettingsService screenSettingsService;

    /**
     * 查询大屏设置表单管理列表
     */
    @ApiOperation("查询大屏设置表单管理列表")
    @PreAuthorize("@ss.hasPermi('hnyz:screenSettings:list')")
    @GetMapping("/formList")
    public TableDataInfo list(@ApiParam("大屏设置参数") ScreenSettings screenSettings)
    {
        startPage();
        List<ScreenSettingsFormVO> list = screenSettingsService.selectScreenSettingsFormList(screenSettings);
        return getDataTable(list);
    }

    /**
     * 导出大屏设置管理列表
     */
    @PreAuthorize("@ss.hasPermi('hnyz:screenSettings:export')")
    @Log(title = "大屏设置管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScreenSettings screenSettings)
    {
        List<ScreenSettings> list = screenSettingsService.selectScreenSettingsList(screenSettings);
        ExcelUtil<ScreenSettings> util = new ExcelUtil<ScreenSettings>(ScreenSettings.class);
        util.exportExcel(response, list, "大屏设置管理数据");
    }

    /**
     * 获取大屏设置管理详细信息
     */
    @ApiOperation("获取大屏设置管理详细信息")
    @PreAuthorize("@ss.hasPermi('hnyz:screenSettings:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@ApiParam("大屏配置id") @PathVariable("id") Long id)
    {
        return success(screenSettingsService.selectScreenSettingsById(id));
    }

    /**
     * 新增大屏设置管理
     */
    @ApiOperation("新增大屏设置管理")
    @PreAuthorize("@ss.hasPermi('hnyz:screenSettings:add')")
    @Log(title = "大屏设置管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScreenSettings screenSettings)
    {
        return toAjax(screenSettingsService.insertScreenSettings(screenSettings));
    }

    /**
     * 修改大屏设置管理
     */
    @ApiOperation("修改大屏设置管理")
    @PreAuthorize("@ss.hasPermi('hnyz:screenSettings:edit')")
    @Log(title = "大屏设置管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScreenSettings screenSettings)
    {
        return toAjax(screenSettingsService.updateScreenSettings(screenSettings));
    }

    /**
     * 删除大屏设置管理
     */
    @ApiOperation("删除大屏设置管理")
    @PreAuthorize("@ss.hasPermi('hnyz:screenSettings:remove')")
    @Log(title = "大屏设置管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@ApiParam("大屏配置id数组") @PathVariable Long[] ids)
    {
        return toAjax(screenSettingsService.deleteScreenSettingsByIds(ids));
    }

    /**
     * 修改启用状态
     */
    @PreAuthorize("@ss.hasPermi('hnyz:screenSettings:edit')")
    @Log(title = "大屏设置管理", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody ScreenSettings screenSettings){
        return toAjax(screenSettingsService.updateScreenSettings(screenSettings));
    }
}
