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.BusiDrillEva;
import com.goldenwater.slaj.eme.service.IBusiDrillEvaService;

/**
 * 应急演练评估
 */
@RestController
@RequestMapping("/eme/drilleva")
public class BusiDrillEvaController extends BaseController {
    @Autowired
    private IBusiDrillEvaService busiDrillEvaService;

    @GetMapping("/list")
    public TableDataInfo list(BusiDrillEva busiDrillEva) {
        startPage();
        List<BusiDrillEva> list = busiDrillEvaService.selectBusiDrillEvaList(busiDrillEva);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BusiDrillEva busiDrillEva) {
        return toAjax(busiDrillEvaService.insertBusiDrillEva(busiDrillEva));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BusiDrillEva busiDrillEva) {
        return toAjax(busiDrillEvaService.updateBusiDrillEva(busiDrillEva));
    }

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

    @Log(title = "应急演练评估管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('eme:drilleva:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusiDrillEva busiDrillEva) {
        List<BusiDrillEva> list = busiDrillEvaService.selectBusiDrillEvaList(busiDrillEva);
        ExcelUtil<BusiDrillEva> util = new ExcelUtil<BusiDrillEva>(BusiDrillEva.class);
        util.exportExcel(response, list, "应急演练评估数据");
    }
}
