package com.goldenwater.slaj.stan.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.stan.domain.BisStanCert;
import com.goldenwater.slaj.stan.service.IBisStanCertService;

@RestController
@RequestMapping("/stan/stancert")
public class BisStanCertController extends BaseController {
    @Autowired
    private IBisStanCertService bisStanCertService;

    @GetMapping("/list")
    public TableDataInfo list(BisStanCert bisStanCert) { startPage(); List<BisStanCert> list = bisStanCertService.selectBisStanCertList(bisStanCert); return getDataTable(list); }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisStanCert bisStanCert) { return toAjax(bisStanCertService.insertBisStanCert(bisStanCert)); }

    @PutMapping
    public AjaxResult edit(@RequestBody BisStanCert bisStanCert) { return toAjax(bisStanCertService.updateBisStanCert(bisStanCert)); }

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

    @Log(title = "标准化证书管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('stan:stancert:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisStanCert bisStanCert) { List<BisStanCert> list = bisStanCertService.selectBisStanCertList(bisStanCert); ExcelUtil<BisStanCert> util = new ExcelUtil<BisStanCert>(BisStanCert.class); util.exportExcel(response, list, "标准化证书管理数据"); }
}
