package com.zc.business.controller;

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

import com.zc.business.domain.DcEventTrafficCongestion;
import com.zc.business.service.IDcEventTrafficCongestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 交通拥堵事件

"拥堵类型"为事件“事件子类”Controller
 * 
 * @author ruoyi
 * @date 2024-01-12
 */
@Api(tags = "交通拥堵事件")
@RestController
@RequestMapping("/system/congestion")
public class DcEventTrafficCongestionController extends BaseController
{
    @Autowired
    private IDcEventTrafficCongestionService dcEventTrafficCongestionService;

    /**
     * 查询交通拥堵事件

"拥堵类型"为事件“事件子类”列表
     */
    @ApiOperation("查询交通拥堵事件")
    //@PreAuthorize("@ss.hasPermi('system:congestion:list')")
    @GetMapping("/list")
    public TableDataInfo list(DcEventTrafficCongestion dcEventTrafficCongestion)
    {
        startPage();
        List<DcEventTrafficCongestion> list = dcEventTrafficCongestionService.selectDcEventTrafficCongestionList(dcEventTrafficCongestion);
        return getDataTable(list);
    }

    /**
     * 导出交通拥堵事件

"拥堵类型"为事件“事件子类”列表
     */

    //@PreAuthorize("@ss.hasPermi('system:congestion:export')")
    @Log(title = "交通拥堵事件 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DcEventTrafficCongestion dcEventTrafficCongestion)
    {
        List<DcEventTrafficCongestion> list = dcEventTrafficCongestionService.selectDcEventTrafficCongestionList(dcEventTrafficCongestion);
        ExcelUtil<DcEventTrafficCongestion> util = new ExcelUtil<>(DcEventTrafficCongestion.class);
        util.exportExcel(response, list, "交通拥堵事件 ");
    }

    /**
     * 获取交通拥堵事件

"拥堵类型"为事件“事件子类”详细信息
     */
    @ApiOperation("获取交通拥堵事件")
   // @PreAuthorize("@ss.hasPermi('system:congestion:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(dcEventTrafficCongestionService.selectDcEventTrafficCongestionById(id));
    }

    /**
     * 新增交通拥堵事件

"拥堵类型"为事件“事件子类”
     */
    @ApiOperation("新增交通拥堵事件")
    //@PreAuthorize("@ss.hasPermi('system:congestion:add')")
    @Log(title = "交通拥堵事件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DcEventTrafficCongestion dcEventTrafficCongestion)
    {
        return toAjax(dcEventTrafficCongestionService.insertDcEventTrafficCongestion(dcEventTrafficCongestion));
    }

    /**
     * 修改交通拥堵事件

"拥堵类型"为事件“事件子类”
     */
    @ApiOperation("修改交通拥堵事件")
   // @PreAuthorize("@ss.hasPermi('system:congestion:edit')")
    @Log(title = "交通拥堵事件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DcEventTrafficCongestion dcEventTrafficCongestion)
    {
        return toAjax(dcEventTrafficCongestionService.updateDcEventTrafficCongestion(dcEventTrafficCongestion));
    }

    /**
     * 删除交通拥堵事件

"拥堵类型"为事件“事件子类”
     */
    @ApiOperation("删除交通拥堵事件")
 //   @PreAuthorize("@ss.hasPermi('system:congestion:remove')")
    @Log(title = "交通拥堵事件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dcEventTrafficCongestionService.deleteDcEventTrafficCongestionByIds(ids));
    }
}