package com.ruoyi.system.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.SysScreenLocation;
import com.ruoyi.system.domain.dto.SysScreenLocationDto;
import com.ruoyi.system.domain.vo.SysScreenLocationVo;
import com.ruoyi.system.domain.vo.SysScreenModuleVo;
import com.ruoyi.system.service.ISysScreenLocationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

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

/**
 * 大屏模块位置Controller
 *
 * @author tianyongbao
 * @date 2023-12-22
 */
@Api(tags=" 大屏模块位置")
@RestController
@RequestMapping("/screenLocation")
public class SysScreenLocationController extends BaseController
{
    @Resource
    private ISysScreenLocationService sysScreenLocationService;

    /**
     * 查询大屏可视化配置模块列表
     */
    @ApiOperation(value="查询大屏可视化配置模块列表",response = SysScreenModuleVo.class)
    @RequiresPermissions("light:module:list")
    @GetMapping("/moduleList")
    public TableDataInfo getModuleList()
    {
        List<SysScreenModuleVo> list = sysScreenLocationService.selectSysScreenModuleList();
        return getDataTable(list);
    }

    /**
     * 查询大屏模块位置列表
     */
    @ApiOperation(value="查询大屏模块位置列表",response = SysScreenLocationVo.class)
    @GetMapping("/list")
    public TableDataInfo list(SysScreenLocationDto sysScreenLocationDto)
    {
        startPage();
        List<SysScreenLocationVo> list = sysScreenLocationService.selectSysScreenLocationList(sysScreenLocationDto);
        return getDataTable(list);
    }

    /**
     * 导出大屏模块位置列表
     */
    @ApiOperation(value="导出大屏模块位置列表")
    @RequiresPermissions("system:screenLocation:export")
    @Log(title = "大屏模块位置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysScreenLocationDto sysScreenLocationDto)
    {
        List<SysScreenLocationVo> list = sysScreenLocationService.selectSysScreenLocationList(sysScreenLocationDto);
        ExcelUtil<SysScreenLocationVo> util = new ExcelUtil<SysScreenLocationVo>(SysScreenLocationVo.class);
        util.exportExcel(response, list, "大屏模块位置数据");
    }

    /**
     * 获取大屏模块位置详细信息
     */
    @ApiOperation(value="获取大屏模块位置详细信息")
    @RequiresPermissions("system:screenLocation:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysScreenLocationService.selectSysScreenLocationById(id));
    }

    /**
     * 新增大屏模块位置
     */
    @ApiOperation(value="新增大屏模块位置")
    @Log(title = "大屏模块位置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysScreenLocation sysScreenLocation)
    {
        return toAjax(sysScreenLocationService.insertSysScreenLocation(sysScreenLocation));
    }

    /**
     * 修改大屏模块位置
     */
    @ApiOperation(value="修改大屏模块位置")
    @Log(title = "大屏模块位置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysScreenLocation sysScreenLocation)
    {
        return toAjax(sysScreenLocationService.updateSysScreenLocation(sysScreenLocation));
    }

    /**
     * 删除大屏模块位置
     */
    @ApiOperation(value="删除大屏模块位置")
    @RequiresPermissions("system:screenLocation:remove")
    @Log(title = "大屏模块位置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysScreenLocationService.deleteSysScreenLocationByIds(ids));
    }
}
