package com.goldenwater.slaj.ttsa.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.ttsa.domain.BisTtsaCertArray;
import com.goldenwater.slaj.ttsa.service.IBisTtsaCertArrayService;

@RestController
@RequestMapping("/ttsa/ttsacertarray")
public class BisTtsaCertArrayController extends BaseController {
    @Autowired
    private IBisTtsaCertArrayService bisTtsaCertArrayService;

    @GetMapping("/list")
    public TableDataInfo list(BisTtsaCertArray bisTtsaCertArray) {
        startPage();
        List<BisTtsaCertArray> list = bisTtsaCertArrayService.selectBisTtsaCertArrayList(bisTtsaCertArray);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisTtsaCertArray bisTtsaCertArray) {
        return toAjax(bisTtsaCertArrayService.insertBisTtsaCertArray(bisTtsaCertArray));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisTtsaCertArray bisTtsaCertArray) {
        return toAjax(bisTtsaCertArrayService.updateBisTtsaCertArray(bisTtsaCertArray));
    }

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

    @Log(title = "证书阵列管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ttsa:ttsacertarray:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisTtsaCertArray bisTtsaCertArray) {
        List<BisTtsaCertArray> list = bisTtsaCertArrayService.selectBisTtsaCertArrayList(bisTtsaCertArray);
        ExcelUtil<BisTtsaCertArray> util = new ExcelUtil<BisTtsaCertArray>(BisTtsaCertArray.class);
        util.exportExcel(response, list, "证书阵列管理数据");
    }
}
