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

/**
 * 应急预案评审信息
 */
@RestController
@RequestMapping("/eme/reviewinfo")
public class BusiReviewInfoController extends BaseController {
    @Autowired
    private IBusiReviewInfoService busiReviewInfoService;

    @GetMapping("/list")
    public TableDataInfo list(BusiReviewInfo busiReviewInfo) {
        startPage();
        List<BusiReviewInfo> list = busiReviewInfoService.selectBusiReviewInfoList(busiReviewInfo);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BusiReviewInfo busiReviewInfo) {
        return toAjax(busiReviewInfoService.insertBusiReviewInfo(busiReviewInfo));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BusiReviewInfo busiReviewInfo) {
        return toAjax(busiReviewInfoService.updateBusiReviewInfo(busiReviewInfo));
    }

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

    @Log(title = "应急预案评审信息管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('eme:reviewinfo:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusiReviewInfo busiReviewInfo) {
        List<BusiReviewInfo> list = busiReviewInfoService.selectBusiReviewInfoList(busiReviewInfo);
        ExcelUtil<BusiReviewInfo> util = new ExcelUtil<BusiReviewInfo>(BusiReviewInfo.class);
        util.exportExcel(response, list, "应急预案评审信息数据");
    }
}
