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

/**
 * 安全生产责任保险评估
 */
@RestController
@RequestMapping("/eme/insureeva")
public class BusiInsureEvaController extends BaseController {
    @Autowired
    private IBusiInsureEvaService busiInsureEvaService;

    @GetMapping("/list")
    public TableDataInfo list(BusiInsureEva busiInsureEva) {
        startPage();
        List<BusiInsureEva> list = busiInsureEvaService.selectBusiInsureEvaList(busiInsureEva);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BusiInsureEva busiInsureEva) {
        return toAjax(busiInsureEvaService.insertBusiInsureEva(busiInsureEva));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BusiInsureEva busiInsureEva) {
        return toAjax(busiInsureEvaService.updateBusiInsureEva(busiInsureEva));
    }

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

    @Log(title = "安全生产责任保险评估管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('eme:insureeva:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusiInsureEva busiInsureEva) {
        List<BusiInsureEva> list = busiInsureEvaService.selectBusiInsureEvaList(busiInsureEva);
        ExcelUtil<BusiInsureEva> util = new ExcelUtil<BusiInsureEva>(BusiInsureEva.class);
        util.exportExcel(response, list, "安全生产责任保险评估数据");
    }
}
