package com.ruoyi.mall.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mall.domain.MallCameraVideo;
import com.ruoyi.mall.service.IMallCameraVideoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 摄像头视频Controller
 *
 * @author LCL
 * @date 2024-03-29
 */
@RestController
@RequestMapping("/mall/mallCameraVideo")
public class MallCameraVideoController extends BaseController
{
    @Resource
    private IMallCameraVideoService mallCameraVideoService;

    /**
     * 查询摄像头视频列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCameraVideo:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallCameraVideo mallCameraVideo)
    {
        startPage();
        List<MallCameraVideo> list = mallCameraVideoService.selectMallCameraVideoList(mallCameraVideo);
        return getDataTable(list);
    }

    /**
     * 导出摄像头视频列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCameraVideo:export')")
    @Log(title = "摄像头视频", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallCameraVideo mallCameraVideo)
    {
        List<MallCameraVideo> list = mallCameraVideoService.selectMallCameraVideoList(mallCameraVideo);
        ExcelUtil<MallCameraVideo> util = new ExcelUtil<MallCameraVideo>(MallCameraVideo.class);
        util.exportExcel(response, list, "摄像头视频数据");
    }

    /**
     * 获取摄像头视频详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCameraVideo:query')")
    @GetMapping(value = "/{cameraVideoId}")
    public AjaxResult getInfo(@PathVariable("cameraVideoId") Long cameraVideoId)
    {
        return AjaxResult.success(mallCameraVideoService.selectMallCameraVideoByCameraVideoId(cameraVideoId));
    }

    /**
     * 新增摄像头视频
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCameraVideo:add')")
    @Log(title = "摄像头视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallCameraVideo mallCameraVideo)
    {
        return toAjax(mallCameraVideoService.insertMallCameraVideo(mallCameraVideo));
    }

    /**
     * 修改摄像头视频
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCameraVideo:edit')")
    @Log(title = "摄像头视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallCameraVideo mallCameraVideo)
    {
        return toAjax(mallCameraVideoService.updateMallCameraVideo(mallCameraVideo));
    }

    /**
     * 删除摄像头视频
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCameraVideo:remove')")
    @Log(title = "摄像头视频", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cameraVideoIds}")
    public AjaxResult remove(@PathVariable Long[] cameraVideoIds)
    {
        return toAjax(mallCameraVideoService.deleteMallCameraVideoByCameraVideoIds(cameraVideoIds));
    }
}
