package com.ruoyi.SafetyDeclaration.controller.sidebarPc;

import java.util.List;
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.SafetyDeclaration.domain.SafetyDeclarationTable;
import com.ruoyi.SafetyDeclaration.service.ISafetyDeclarationTableService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 水电校园安全不良事件
Controller
 * 
 * @author ruoyi
 * @date 2024-08-04
 */
@RestController
@RequestMapping("/sidebarPc/safetyDeclaration")
public class SafetyDeclarationPcController extends BaseController
{
    @Autowired
    private ISafetyDeclarationTableService safetyDeclarationTableService;

    /**
     * 查询水电校园安全不良事件
列表
     */
    @PreAuthorize("@ss.hasPermi('sidebar:safetyDeclaration:list')")
    @GetMapping("/list")
    public TableDataInfo list(SafetyDeclarationTable safetyDeclarationTable)
    {
        startPage();
        List<SafetyDeclarationTable> list = safetyDeclarationTableService.selectSafetyDeclarationTableList(safetyDeclarationTable);
        return getDataTable(list);
    }

    /**
     * 导出水电校园安全不良事件
列表
     */
    @PreAuthorize("@ss.hasPermi('sidebar:safetyDeclaration:export')")
    @Log(title = "水电校园安全不良事件 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SafetyDeclarationTable safetyDeclarationTable)
    {
        List<SafetyDeclarationTable> list = safetyDeclarationTableService.selectSafetyDeclarationTableList(safetyDeclarationTable);
        ExcelUtil<SafetyDeclarationTable> util = new ExcelUtil<SafetyDeclarationTable>(SafetyDeclarationTable.class);
        util.exportExcel(response, list, "水电校园安全不良事件 数据");
    }

    /**
     * 获取水电校园安全不良事件
详细信息
     */
    @PreAuthorize("@ss.hasPermi('sidebar:safetyDeclaration:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(safetyDeclarationTableService.selectSafetyDeclarationTableById(id));
    }

    /**
     * 新增水电校园安全不良事件

     */
    @PreAuthorize("@ss.hasPermi('sidebar:safetyDeclaration:add')")
    @Log(title = "水电校园安全不良事件 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SafetyDeclarationTable safetyDeclarationTable)
    {
        return toAjax(safetyDeclarationTableService.insertSafetyDeclarationTable(safetyDeclarationTable));
    }

    /**
     * 修改水电校园安全不良事件

     */
    @PreAuthorize("@ss.hasPermi('sidebar:safetyDeclaration:edit')")
    @Log(title = "水电校园安全不良事件 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SafetyDeclarationTable safetyDeclarationTable)
    {
        return toAjax(safetyDeclarationTableService.updateSafetyDeclarationTable(safetyDeclarationTable));
    }

    /**
     * 删除水电校园安全不良事件

     */
    @PreAuthorize("@ss.hasPermi('sidebar:safetyDeclaration:remove')")
    @Log(title = "水电校园安全不良事件 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(safetyDeclarationTableService.deleteSafetyDeclarationTableByIds(ids));
    }
}
