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

@RestController
@RequestMapping("/ttsa/ttsaexamente")
public class BisTtsaExamEnteController extends BaseController {
    @Autowired
    private IBisTtsaExamEnteService bisTtsaExamEnteService;

    @GetMapping("/list")
    public TableDataInfo list(BisTtsaExamEnte bisTtsaExamEnte) {
        startPage();
        List<BisTtsaExamEnte> list = bisTtsaExamEnteService.selectBisTtsaExamEnteList(bisTtsaExamEnte);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisTtsaExamEnte bisTtsaExamEnte) {
        return toAjax(bisTtsaExamEnteService.insertBisTtsaExamEnte(bisTtsaExamEnte));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisTtsaExamEnte bisTtsaExamEnte) {
        return toAjax(bisTtsaExamEnteService.updateBisTtsaExamEnte(bisTtsaExamEnte));
    }

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

    @Log(title = "考核企业管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ttsa:ttsaexamente:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisTtsaExamEnte bisTtsaExamEnte) {
        List<BisTtsaExamEnte> list = bisTtsaExamEnteService.selectBisTtsaExamEnteList(bisTtsaExamEnte);
        ExcelUtil<BisTtsaExamEnte> util = new ExcelUtil<BisTtsaExamEnte>(BisTtsaExamEnte.class);
        util.exportExcel(response, list, "考核企业管理数据");
    }
}
