package com.goldenwater.slaj.eme.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.goldenwater.common.annotation.Log;
import com.goldenwater.common.core.controller.BaseController;
import com.goldenwater.common.core.domain.AjaxResult;
import com.goldenwater.common.core.page.TableDataInfo;
import com.goldenwater.common.enums.BusinessType;
import com.goldenwater.common.utils.poi.ExcelUtil;
import com.goldenwater.slaj.eme.domain.BusiPlanEva;
import com.goldenwater.slaj.eme.service.IBusiPlanEvaService;

/**
 * 应急预案评估
 */
@RestController
@RequestMapping("/eme/planeva")
public class BusiPlanEvaController extends BaseController {
    @Autowired
    private IBusiPlanEvaService busiPlanEvaService;

    @GetMapping("/list")
    public TableDataInfo list(BusiPlanEva busiPlanEva) {
        startPage();
        List<BusiPlanEva> list = busiPlanEvaService.selectBusiPlanEvaList(busiPlanEva);
        return getDataTable(list);
    }

    @GetMapping("/{guid}")
    public AjaxResult getInfo(@PathVariable String guid) {
        return AjaxResult.success(busiPlanEvaService.selectBusiPlanEvaByGuid(guid));
    }

    @PostMapping
    public AjaxResult add(@RequestBody BusiPlanEva busiPlanEva) {
        return toAjax(busiPlanEvaService.insertBusiPlanEva(busiPlanEva));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BusiPlanEva busiPlanEva) {
        return toAjax(busiPlanEvaService.updateBusiPlanEva(busiPlanEva));
    }

    @DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids) {
        return toAjax(busiPlanEvaService.deleteBusiPlanEvaByGuids(guids));
    }

    @Log(title = "应急预案评估管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('eme:planeva:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusiPlanEva busiPlanEva) {
        List<BusiPlanEva> list = busiPlanEvaService.selectBusiPlanEvaList(busiPlanEva);
        ExcelUtil<BusiPlanEva> util = new ExcelUtil<BusiPlanEva>(BusiPlanEva.class);
        util.exportExcel(response, list, "应急预案评估数据");
    }
}
