package com.zc.business.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.zc.business.domain.DcEventServiceArea;
import com.zc.business.enums.UniversalEnum;
import com.zc.business.service.IDcEventServiceAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 服务区异常事件

"异常分类"为事件“事件子类”Controller
 *
 * @author ruoyi
 * @date 2024-01-12
 */
@Api(tags = "服务区异常事件")
@RestController
@RequestMapping("/system/area")
public class DcEventServiceAreaController extends BaseController
{
    @Autowired
    private IDcEventServiceAreaService dcEventServiceAreaService;

    /**
     * 查询服务区异常事件

"异常分类"为事件“事件子类”列表
     */
    @ApiOperation("查询服务区异常事件")
   // @PreAuthorize("@ss.hasPermi('system:area:list')")
    @GetMapping("/list")
    public TableDataInfo list(DcEventServiceArea dcEventServiceArea)
    {
        startPage();
        List<DcEventServiceArea> list = dcEventServiceAreaService.selectDcEventServiceAreaList(dcEventServiceArea);
        return getDataTable(list);
    }

    /**
     * 导出服务区异常事件

"异常分类"为事件“事件子类”列表
     */
    @ApiOperation("导出服务区异常事件")
   // @PreAuthorize("@ss.hasPermi('system:area:export')")
    @Log(title = "服务区异常事异常分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DcEventServiceArea dcEventServiceArea)
    {
        List<DcEventServiceArea> list = dcEventServiceAreaService.selectDcEventServiceAreaList(dcEventServiceArea);
        ExcelUtil<DcEventServiceArea> util = new ExcelUtil<>(DcEventServiceArea.class);
        util.exportExcel(response, list, UniversalEnum.SERVICE_AREA_EXCEPTION_EVENT.getValue());
    }

    /**
     * 获取服务区异常事件

"异常分类"为事件“事件子类”详细信息
     */
    @ApiOperation("获取服务区异常事件")
    //@PreAuthorize("@ss.hasPermi('system:area:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(dcEventServiceAreaService.selectDcEventServiceAreaById(id));
    }

    /**
     * 新增服务区异常事件

"异常分类"为事件“事件子类”
     */
    @ApiOperation("新增服务区异常事件")
    //@PreAuthorize("@ss.hasPermi('system:area:add')")
    @Log(title = "服务区异常事件 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DcEventServiceArea dcEventServiceArea)
    {
        return toAjax(dcEventServiceAreaService.insertDcEventServiceArea(dcEventServiceArea));
    }

    /**
     * 修改服务区异常事件

"异常分类"为事件“事件子类”
     */
    @ApiOperation("修改服务区异常事件")
  //  @PreAuthorize("@ss.hasPermi('system:area:edit')")
    @Log(title = "服务区异常事件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DcEventServiceArea dcEventServiceArea)
    {
        return toAjax(dcEventServiceAreaService.updateDcEventServiceArea(dcEventServiceArea));
    }

    /**
     * 删除服务区异常事件

"异常分类"为事件“事件子类”
     */
    @ApiOperation("删除服务区异常事件")
   // @PreAuthorize("@ss.hasPermi('system:area:remove')")
    @Log(title = "服务区异常事件 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dcEventServiceAreaService.deleteDcEventServiceAreaByIds(ids));
    }
}