package com.goldenwater.slaj.acci.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.acci.domain.SawfSafeSupe;
import com.goldenwater.slaj.acci.service.ISawfSafeSupeService;

/**
 * 安全生产许可证信息
 */
@RestController
@RequestMapping("/acci/sawfsafesupe")
public class SawfSafeSupeController extends BaseController {
    @Autowired
    private ISawfSafeSupeService sawfSafeSupeService;

    @GetMapping("/list")
    public TableDataInfo list(SawfSafeSupe sawfSafeSupe) {
        startPage();
        List<SawfSafeSupe> list = sawfSafeSupeService.selectSawfSafeSupeList(sawfSafeSupe);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody SawfSafeSupe sawfSafeSupe) {
        return toAjax(sawfSafeSupeService.insertSawfSafeSupe(sawfSafeSupe));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody SawfSafeSupe sawfSafeSupe) {
        return toAjax(sawfSafeSupeService.updateSawfSafeSupe(sawfSafeSupe));
    }

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

    @Log(title = "安全生产许可证信息管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('acci:sawfsafesupe:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, SawfSafeSupe sawfSafeSupe) {
        List<SawfSafeSupe> list = sawfSafeSupeService.selectSawfSafeSupeList(sawfSafeSupe);
        ExcelUtil<SawfSafeSupe> util = new ExcelUtil<SawfSafeSupe>(SawfSafeSupe.class);
        util.exportExcel(response, list, "安全生产许可证信息数据");
    }
}
