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

@RestController
@RequestMapping("/eutr/record")
public class BisEutrRecController extends BaseController {
    @Autowired
    private IBisEutrRecService bisEutrRecService;

    @GetMapping("/list")
    public TableDataInfo list(BisEutrRec bisEutrRec) {
        startPage();
        List<BisEutrRec> list = bisEutrRecService.selectBisEutrRecList(bisEutrRec);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisEutrRec bisEutrRec) {
        return toAjax(bisEutrRecService.insertBisEutrRec(bisEutrRec));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisEutrRec bisEutrRec) {
        return toAjax(bisEutrRecService.updateBisEutrRec(bisEutrRec));
    }

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

    @Log(title = "培训记录管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('eutr:record:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisEutrRec bisEutrRec) {
        List<BisEutrRec> list = bisEutrRecService.selectBisEutrRecList(bisEutrRec);
        ExcelUtil<BisEutrRec> util = new ExcelUtil<BisEutrRec>(BisEutrRec.class);
        util.exportExcel(response, list, "培训记录数据");
    }
}
