package com.dcsoft.system.camera.controller;

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

import com.dcsoft.system.camera.domain.TbCameraWarn;
import com.dcsoft.system.camera.service.ITbCameraWarnService;
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.dcsoft.common.log.annotation.Log;
import com.dcsoft.common.log.enums.BusinessType;
import com.dcsoft.common.security.annotation.RequiresPermissions;

import com.dcsoft.common.core.web.controller.BaseController;
import com.dcsoft.common.core.web.domain.AjaxResult;
import com.dcsoft.common.core.utils.poi.ExcelUtil;
import com.dcsoft.common.core.web.page.TableDataInfo;


/**
 * 视频预警Controller
 *
 * @author nichun
 * @date 2023-09-20
 */
@RestController
@RequestMapping("/cameraWarn")
public class TbCameraWarnController extends BaseController
{
    @Autowired
    private ITbCameraWarnService tbCameraWarnService;

    /**
     * 查询视频预警列表
     */
    @RequiresPermissions("system:cameraWarn:list")
    @GetMapping("/list")
    public TableDataInfo list(TbCameraWarn tbCameraWarn)
    {
        startPage();
        List<TbCameraWarn> list = tbCameraWarnService.selectTbCameraWarnList(tbCameraWarn);
        return getDataTable(list);
    }

    /**
     * 导出视频预警列表
     */
    @RequiresPermissions("system:cameraWarn:export")
    @Log(title = "视频预警", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbCameraWarn tbCameraWarn)
    {
        List<TbCameraWarn> list = tbCameraWarnService.selectTbCameraWarnList(tbCameraWarn);
        ExcelUtil<TbCameraWarn> util = new ExcelUtil<TbCameraWarn>(TbCameraWarn.class);
        util.exportExcel(response, list, "视频预警数据");
    }

    /**
     * 获取视频预警详细信息
     */
    @RequiresPermissions("system:cameraWarn:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbCameraWarnService.selectTbCameraWarnById(id));
    }

    /**
     * 新增视频预警
     */
    @RequiresPermissions("system:cameraWarn:add")
    @Log(title = "视频预警", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbCameraWarn tbCameraWarn)
    {
        return toAjax(tbCameraWarnService.insertTbCameraWarn(tbCameraWarn));
    }

    /**
     * 修改视频预警
     */
    @RequiresPermissions("system:cameraWarn:edit")
    @Log(title = "视频预警", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbCameraWarn tbCameraWarn)
    {
        return toAjax(tbCameraWarnService.updateTbCameraWarn(tbCameraWarn));
    }

    /**
     * 删除视频预警
     */
    @RequiresPermissions("system:cameraWarn:remove")
    @Log(title = "视频预警", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbCameraWarnService.deleteTbCameraWarnByIds(ids));
    }
}
