package com.goldenwater.slaj.hidd.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.goldenwater.common.core.controller.BaseController;
import com.goldenwater.common.core.domain.AjaxResult;
import com.goldenwater.common.core.page.TableDataInfo;
import com.goldenwater.slaj.hidd.domain.BisHiddConsult;
import com.goldenwater.slaj.hidd.service.IBisHiddConsultService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import com.goldenwater.common.annotation.Log;
import com.goldenwater.common.enums.BusinessType;
import com.goldenwater.common.utils.poi.ExcelUtil;

/**
 * 隐患会商信息
 */
@RestController
@RequestMapping("/hidd/cons")
public class BisHiddConsultController extends BaseController {
    @Autowired
    private IBisHiddConsultService bisHiddConsultService;

    @GetMapping("/list")
    public TableDataInfo list(BisHiddConsult bisHiddConsult) {
        startPage();
        List<BisHiddConsult> list = bisHiddConsultService.selectBisHiddConsultList(bisHiddConsult);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisHiddConsult bisHiddConsult) {
        return toAjax(bisHiddConsultService.insertBisHiddConsult(bisHiddConsult));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisHiddConsult bisHiddConsult) {
        return toAjax(bisHiddConsultService.updateBisHiddConsult(bisHiddConsult));
    }

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

    @Log(title = "隐患会商管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('hidd:cons:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisHiddConsult bisHiddConsult) {
        List<BisHiddConsult> list = bisHiddConsultService.selectBisHiddConsultList(bisHiddConsult);
        ExcelUtil<BisHiddConsult> util = new ExcelUtil<>(BisHiddConsult.class);
        util.exportExcel(response, list, "隐患会商数据");
    }
}
