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.BisTtsaCertChaAppl;
import com.goldenwater.slaj.ttsa.service.IBisTtsaCertChaApplService;

@RestController
@RequestMapping("/ttsa/ttsacertchaappl")
public class BisTtsaCertChaApplController extends BaseController {
    @Autowired
    private IBisTtsaCertChaApplService bisTtsaCertChaApplService;

    @GetMapping("/list")
    public TableDataInfo list(BisTtsaCertChaAppl bisTtsaCertChaAppl) {
        startPage();
        List<BisTtsaCertChaAppl> list = bisTtsaCertChaApplService.selectBisTtsaCertChaApplList(bisTtsaCertChaAppl);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisTtsaCertChaAppl bisTtsaCertChaAppl) {
        return toAjax(bisTtsaCertChaApplService.insertBisTtsaCertChaAppl(bisTtsaCertChaAppl));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisTtsaCertChaAppl bisTtsaCertChaAppl) {
        return toAjax(bisTtsaCertChaApplService.updateBisTtsaCertChaAppl(bisTtsaCertChaAppl));
    }

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

    @Log(title = "证书变更申请管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ttsa:ttsacertchaappl:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisTtsaCertChaAppl bisTtsaCertChaAppl) {
        List<BisTtsaCertChaAppl> list = bisTtsaCertChaApplService.selectBisTtsaCertChaApplList(bisTtsaCertChaAppl);
        ExcelUtil<BisTtsaCertChaAppl> util = new ExcelUtil<BisTtsaCertChaAppl>(BisTtsaCertChaAppl.class);
        util.exportExcel(response, list, "证书变更申请管理数据");
    }
}
