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

@RestController
@RequestMapping("/eutr/offlrec")
public class BisEutrOfflRecController extends BaseController {
    @Autowired
    private IBisEutrOfflRecService bisEutrOfflRecService;

    @GetMapping("/list")
    public TableDataInfo list(BisEutrOfflRec bisEutrOfflRec) {
        startPage();
        List<BisEutrOfflRec> list = bisEutrOfflRecService.selectBisEutrOfflRecList(bisEutrOfflRec);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisEutrOfflRec bisEutrOfflRec) {
        return toAjax(bisEutrOfflRecService.insertBisEutrOfflRec(bisEutrOfflRec));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisEutrOfflRec bisEutrOfflRec) {
        return toAjax(bisEutrOfflRecService.updateBisEutrOfflRec(bisEutrOfflRec));
    }

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

    @Log(title = "线下培训记录管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('eutr:offlrec:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisEutrOfflRec bisEutrOfflRec) {
        List<BisEutrOfflRec> list = bisEutrOfflRecService.selectBisEutrOfflRecList(bisEutrOfflRec);
        ExcelUtil<BisEutrOfflRec> util = new ExcelUtil<BisEutrOfflRec>(BisEutrOfflRec.class);
        util.exportExcel(response, list, "线下培训记录数据");
    }
}
