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

/**
 * 应急预案基本信息
 */
@RestController
@RequestMapping("/eme/conplanbasic")
public class BusiConplanBasicController extends BaseController {
    @Autowired
    private IBusiConplanBasicService busiConplanBasicService;

    @GetMapping("/list")
    public TableDataInfo list(BusiConplanBasic busiConplanBasic) {
        startPage();
        List<BusiConplanBasic> list = busiConplanBasicService.selectBusiConplanBasicList(busiConplanBasic);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BusiConplanBasic busiConplanBasic) {
        return toAjax(busiConplanBasicService.insertBusiConplanBasic(busiConplanBasic));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BusiConplanBasic busiConplanBasic) {
        return toAjax(busiConplanBasicService.updateBusiConplanBasic(busiConplanBasic));
    }

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

    @Log(title = "应急预案基本信息管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('eme:conplanbasic:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusiConplanBasic busiConplanBasic) {
        List<BusiConplanBasic> list = busiConplanBasicService.selectBusiConplanBasicList(busiConplanBasic);
        ExcelUtil<BusiConplanBasic> util = new ExcelUtil<BusiConplanBasic>(BusiConplanBasic.class);
        util.exportExcel(response, list, "应急预案基本信息数据");
    }
}
