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.BisEutrExam;
import com.goldenwater.slaj.eutr.service.IBisEutrExamService;

@RestController
@RequestMapping("/eutr/exam")
public class BisEutrExamController extends BaseController {
    @Autowired
    private IBisEutrExamService bisEutrExamService;

    @GetMapping("/list")
    public TableDataInfo list(BisEutrExam bisEutrExam) {
        startPage();
        List<BisEutrExam> list = bisEutrExamService.selectBisEutrExamList(bisEutrExam);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisEutrExam bisEutrExam) {
        return toAjax(bisEutrExamService.insertBisEutrExam(bisEutrExam));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisEutrExam bisEutrExam) {
        return toAjax(bisEutrExamService.updateBisEutrExam(bisEutrExam));
    }

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

    @Log(title = "培训考试管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('eutr:exam:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisEutrExam bisEutrExam) {
        List<BisEutrExam> list = bisEutrExamService.selectBisEutrExamList(bisEutrExam);
        ExcelUtil<BisEutrExam> util = new ExcelUtil<BisEutrExam>(BisEutrExam.class);
        util.exportExcel(response, list, "培训考试数据");
    }
}
