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

@RestController
@RequestMapping("/ttsa/ttsacertchatran")
public class BisTtsaCertChaTranController extends BaseController {
    @Autowired
    private IBisTtsaCertChaTranService bisTtsaCertChaTranService;

    @GetMapping("/list")
    public TableDataInfo list(BisTtsaCertChaTran bisTtsaCertChaTran) {
        startPage();
        List<BisTtsaCertChaTran> list = bisTtsaCertChaTranService.selectBisTtsaCertChaTranList(bisTtsaCertChaTran);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisTtsaCertChaTran bisTtsaCertChaTran) {
        return toAjax(bisTtsaCertChaTranService.insertBisTtsaCertChaTran(bisTtsaCertChaTran));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisTtsaCertChaTran bisTtsaCertChaTran) {
        return toAjax(bisTtsaCertChaTranService.updateBisTtsaCertChaTran(bisTtsaCertChaTran));
    }

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

    @Log(title = "证书调动管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ttsa:ttsacertchatran:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisTtsaCertChaTran bisTtsaCertChaTran) {
        List<BisTtsaCertChaTran> list = bisTtsaCertChaTranService.selectBisTtsaCertChaTranList(bisTtsaCertChaTran);
        ExcelUtil<BisTtsaCertChaTran> util = new ExcelUtil<BisTtsaCertChaTran>(BisTtsaCertChaTran.class);
        util.exportExcel(response, list, "证书调动管理数据");
    }
}
