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

@RestController
@RequestMapping("/ttsa/ttsacertchalost")
public class BisTtsaCertChaLostController extends BaseController {
    @Autowired
    private IBisTtsaCertChaLostService bisTtsaCertChaLostService;

    @GetMapping("/list")
    public TableDataInfo list(BisTtsaCertChaLost bisTtsaCertChaLost) {
        startPage();
        List<BisTtsaCertChaLost> list = bisTtsaCertChaLostService.selectBisTtsaCertChaLostList(bisTtsaCertChaLost);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisTtsaCertChaLost bisTtsaCertChaLost) {
        return toAjax(bisTtsaCertChaLostService.insertBisTtsaCertChaLost(bisTtsaCertChaLost));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisTtsaCertChaLost bisTtsaCertChaLost) {
        return toAjax(bisTtsaCertChaLostService.updateBisTtsaCertChaLost(bisTtsaCertChaLost));
    }

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

    @Log(title = "遗失补办管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ttsa:ttsacertchalost:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisTtsaCertChaLost bisTtsaCertChaLost) {
        List<BisTtsaCertChaLost> list = bisTtsaCertChaLostService.selectBisTtsaCertChaLostList(bisTtsaCertChaLost);
        ExcelUtil<BisTtsaCertChaLost> util = new ExcelUtil<BisTtsaCertChaLost>(BisTtsaCertChaLost.class);
        util.exportExcel(response, list, "遗失补办管理数据");
    }
}
