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

@RestController
@RequestMapping("/ttsa/ttsarec")
public class BisTtsaRecController extends BaseController {
    @Autowired
    private IBisTtsaRecService bisTtsaRecService;

    @GetMapping("/list")
    public TableDataInfo list(BisTtsaRec bisTtsaRec) {
        startPage();
        List<BisTtsaRec> list = bisTtsaRecService.selectBisTtsaRecList(bisTtsaRec);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisTtsaRec bisTtsaRec) {
        return toAjax(bisTtsaRecService.insertBisTtsaRec(bisTtsaRec));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisTtsaRec bisTtsaRec) {
        return toAjax(bisTtsaRecService.updateBisTtsaRec(bisTtsaRec));
    }

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

    @Log(title = "考核记录管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ttsa:ttsarec:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisTtsaRec bisTtsaRec) {
        List<BisTtsaRec> list = bisTtsaRecService.selectBisTtsaRecList(bisTtsaRec);
        ExcelUtil<BisTtsaRec> util = new ExcelUtil<BisTtsaRec>(BisTtsaRec.class);
        util.exportExcel(response, list, "考核记录管理数据");
    }
}
