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

@RestController
@RequestMapping("/ttsa/ttsaceriextapll")
public class BisTtsaCeriExtApllController extends BaseController {
    @Autowired
    private IBisTtsaCeriExtApllService bisTtsaCeriExtApllService;

    @GetMapping("/list")
    public TableDataInfo list(BisTtsaCeriExtApll bisTtsaCeriExtApll) {
        startPage();
        List<BisTtsaCeriExtApll> list = bisTtsaCeriExtApllService.selectBisTtsaCeriExtApllList(bisTtsaCeriExtApll);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisTtsaCeriExtApll bisTtsaCeriExtApll) {
        return toAjax(bisTtsaCeriExtApllService.insertBisTtsaCeriExtApll(bisTtsaCeriExtApll));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisTtsaCeriExtApll bisTtsaCeriExtApll) {
        return toAjax(bisTtsaCeriExtApllService.updateBisTtsaCeriExtApll(bisTtsaCeriExtApll));
    }

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

    @Log(title = "延期申请管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ttsa:ttsaceriextapll:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisTtsaCeriExtApll bisTtsaCeriExtApll) {
        List<BisTtsaCeriExtApll> list = bisTtsaCeriExtApllService.selectBisTtsaCeriExtApllList(bisTtsaCeriExtApll);
        ExcelUtil<BisTtsaCeriExtApll> util = new ExcelUtil<BisTtsaCeriExtApll>(BisTtsaCeriExtApll.class);
        util.exportExcel(response, list, "延期申请管理数据");
    }
}
