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

@RestController
@RequestMapping("/eutr/courtoeq")
public class BisEutrCourToEqController extends BaseController {
    @Autowired
    private IBisEutrCourToEqService bisEutrCourToEqService;

    @GetMapping("/list")
    public TableDataInfo list(BisEutrCourToEq bisEutrCourToEq) {
        startPage();
        List<BisEutrCourToEq> list = bisEutrCourToEqService.selectBisEutrCourToEqList(bisEutrCourToEq);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisEutrCourToEq bisEutrCourToEq) {
        return toAjax(bisEutrCourToEqService.insertBisEutrCourToEq(bisEutrCourToEq));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisEutrCourToEq bisEutrCourToEq) {
        return toAjax(bisEutrCourToEqService.updateBisEutrCourToEq(bisEutrCourToEq));
    }

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

    @Log(title = "课程试题关联管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('eutr:courtoeq:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisEutrCourToEq bisEutrCourToEq) {
        List<BisEutrCourToEq> list = bisEutrCourToEqService.selectBisEutrCourToEqList(bisEutrCourToEq);
        ExcelUtil<BisEutrCourToEq> util = new ExcelUtil<BisEutrCourToEq>(BisEutrCourToEq.class);
        util.exportExcel(response, list, "课程试题关联数据");
    }
}
