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

/**
 * 应急预案定期评估
 */
@RestController
@RequestMapping("/eme/regularevalu")
public class BusiRegularEvaluController extends BaseController {
    @Autowired
    private IBusiRegularEvaluService busiRegularEvaluService;

    @GetMapping("/list")
    public TableDataInfo list(BusiRegularEvalu busiRegularEvalu) {
        startPage();
        List<BusiRegularEvalu> list = busiRegularEvaluService.selectBusiRegularEvaluList(busiRegularEvalu);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BusiRegularEvalu busiRegularEvalu) {
        return toAjax(busiRegularEvaluService.insertBusiRegularEvalu(busiRegularEvalu));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BusiRegularEvalu busiRegularEvalu) {
        return toAjax(busiRegularEvaluService.updateBusiRegularEvalu(busiRegularEvalu));
    }

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

    @Log(title = "应急预案定期评估管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('eme:regularevalu:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusiRegularEvalu busiRegularEvalu) {
        List<BusiRegularEvalu> list = busiRegularEvaluService.selectBusiRegularEvaluList(busiRegularEvalu);
        ExcelUtil<BusiRegularEvalu> util = new ExcelUtil<BusiRegularEvalu>(BusiRegularEvalu.class);
        util.exportExcel(response, list, "应急预案定期评估数据");
    }
}
