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

@RestController
@RequestMapping("/ttsa/ttsacertchaname")
public class BisTtsaCertChaNameController extends BaseController {
    @Autowired
    private IBisTtsaCertChaNameService bisTtsaCertChaNameService;

    @GetMapping("/list")
    public TableDataInfo list(BisTtsaCertChaName bisTtsaCertChaName) {
        startPage();
        List<BisTtsaCertChaName> list = bisTtsaCertChaNameService.selectBisTtsaCertChaNameList(bisTtsaCertChaName);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisTtsaCertChaName bisTtsaCertChaName) {
        return toAjax(bisTtsaCertChaNameService.insertBisTtsaCertChaName(bisTtsaCertChaName));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisTtsaCertChaName bisTtsaCertChaName) {
        return toAjax(bisTtsaCertChaNameService.updateBisTtsaCertChaName(bisTtsaCertChaName));
    }

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

    @Log(title = "姓名变更管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ttsa:ttsacertchaname:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisTtsaCertChaName bisTtsaCertChaName) {
        List<BisTtsaCertChaName> list = bisTtsaCertChaNameService.selectBisTtsaCertChaNameList(bisTtsaCertChaName);
        ExcelUtil<BisTtsaCertChaName> util = new ExcelUtil<BisTtsaCertChaName>(BisTtsaCertChaName.class);
        util.exportExcel(response, list, "姓名变更管理数据");
    }
}
