package com.flossom.system.controller;

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

import com.flossom.common.core.domain.entity.WxModeOpenSource;
import com.flossom.common.core.utils.poi.ExcelUtil;
import com.flossom.common.core.web.controller.BaseController;
import com.flossom.common.core.web.domain.AjaxResult;
import com.flossom.common.core.web.page.TableDataInfo;
import com.flossom.common.log.annotation.Log;
import com.flossom.common.log.enums.BusinessType;
import com.flossom.common.security.annotation.RequiresPermissions;
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.flossom.system.service.IWxModeOpenSourceService;

/**
 * IOT仪器弹出视频Controller
 *
 * @author flossom
 * @date 2024-01-29
 */
@RestController
@RequestMapping("/modeOpenSource")
public class WxModeOpenSourceController extends BaseController
{
    @Autowired
    private IWxModeOpenSourceService wxModeOpenSourceService;

    /**
     * 查询IOT仪器弹出视频列表
     */
    @RequiresPermissions("system:modeOpenSource:list")
    @GetMapping("/list")
    public TableDataInfo list(WxModeOpenSource wxModeOpenSource)
    {
        startPage();
        List<WxModeOpenSource> list = wxModeOpenSourceService.selectWxModeOpenSourceList(wxModeOpenSource);
        return getDataTable(list);
    }

    /**
     * 导出IOT仪器弹出视频列表
     */
    @RequiresPermissions("system:modeOpenSource:export")
    @Log(title = "IOT仪器弹出视频", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WxModeOpenSource wxModeOpenSource)
    {
        List<WxModeOpenSource> list = wxModeOpenSourceService.selectWxModeOpenSourceList(wxModeOpenSource);
        ExcelUtil<WxModeOpenSource> util = new ExcelUtil<WxModeOpenSource>(WxModeOpenSource.class);
        util.exportExcel(response, list, "IOT仪器弹出视频数据");
    }

    /**
     * 获取IOT仪器弹出视频详细信息
     */
    @RequiresPermissions("system:modeOpenSource:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wxModeOpenSourceService.selectWxModeOpenSourceById(id));
    }

    /**
     * 新增IOT仪器弹出视频
     */
    @RequiresPermissions("system:modeOpenSource:add")
    @Log(title = "IOT仪器弹出视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxModeOpenSource wxModeOpenSource)
    {
        return toAjax(wxModeOpenSourceService.insertWxModeOpenSource(wxModeOpenSource));
    }

    /**
     * 修改IOT仪器弹出视频
     */
    @RequiresPermissions("system:modeOpenSource:edit")
    @Log(title = "IOT仪器弹出视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxModeOpenSource wxModeOpenSource)
    {
        return toAjax(wxModeOpenSourceService.updateWxModeOpenSource(wxModeOpenSource));
    }

    /**
     * 删除IOT仪器弹出视频
     */
    @RequiresPermissions("system:modeOpenSource:remove")
    @Log(title = "IOT仪器弹出视频", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wxModeOpenSourceService.deleteWxModeOpenSourceByIds(ids));
    }
}
