package com.goldenwater.slaj.eutr.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.eutr.domain.BisEutrExamStra;
import com.goldenwater.slaj.eutr.service.IBisEutrExamStraService;

@RestController
@RequestMapping("/eutr/examstra")
public class BisEutrExamStraController extends BaseController {
    @Autowired
    private IBisEutrExamStraService bisEutrExamStraService;

    @GetMapping("/list")
    public TableDataInfo list(BisEutrExamStra bisEutrExamStra) {
        startPage();
        List<BisEutrExamStra> list = bisEutrExamStraService.selectBisEutrExamStraList(bisEutrExamStra);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisEutrExamStra bisEutrExamStra) {
        return toAjax(bisEutrExamStraService.insertBisEutrExamStra(bisEutrExamStra));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisEutrExamStra bisEutrExamStra) {
        return toAjax(bisEutrExamStraService.updateBisEutrExamStra(bisEutrExamStra));
    }

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

    @Log(title = "考试策略管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('eutr:examstra:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisEutrExamStra bisEutrExamStra) {
        List<BisEutrExamStra> list = bisEutrExamStraService.selectBisEutrExamStraList(bisEutrExamStra);
        ExcelUtil<BisEutrExamStra> util = new ExcelUtil<BisEutrExamStra>(BisEutrExamStra.class);
        util.exportExcel(response, list, "考试策略数据");
    }
}
