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

@RestController
@RequestMapping("/ttsa/ttsacertchapers")
public class BisTtsaCertChaPersController extends BaseController {
    @Autowired
    private IBisTtsaCertChaPersService bisTtsaCertChaPersService;

    @GetMapping("/list")
    public TableDataInfo list(BisTtsaCertChaPers bisTtsaCertChaPers) {
        startPage();
        List<BisTtsaCertChaPers> list = bisTtsaCertChaPersService.selectBisTtsaCertChaPersList(bisTtsaCertChaPers);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisTtsaCertChaPers bisTtsaCertChaPers) {
        return toAjax(bisTtsaCertChaPersService.insertBisTtsaCertChaPers(bisTtsaCertChaPers));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisTtsaCertChaPers bisTtsaCertChaPers) {
        return toAjax(bisTtsaCertChaPersService.updateBisTtsaCertChaPers(bisTtsaCertChaPers));
    }

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

    @Log(title = "人员变更管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ttsa:ttsacertchapers:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisTtsaCertChaPers bisTtsaCertChaPers) {
        List<BisTtsaCertChaPers> list = bisTtsaCertChaPersService.selectBisTtsaCertChaPersList(bisTtsaCertChaPers);
        ExcelUtil<BisTtsaCertChaPers> util = new ExcelUtil<BisTtsaCertChaPers>(BisTtsaCertChaPers.class);
        util.exportExcel(response, list, "人员变更管理数据");
    }
}
