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

@RestController
@RequestMapping("/eutr/eq")
public class BisEutrEqController extends BaseController {
    @Autowired
    private IBisEutrEqService bisEutrEqService;

    @GetMapping("/list")
    public TableDataInfo list(BisEutrEq bisEutrEq) {
        startPage();
        List<BisEutrEq> list = bisEutrEqService.selectBisEutrEqList(bisEutrEq);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisEutrEq bisEutrEq) {
        return toAjax(bisEutrEqService.insertBisEutrEq(bisEutrEq));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisEutrEq bisEutrEq) {
        return toAjax(bisEutrEqService.updateBisEutrEq(bisEutrEq));
    }

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

    @Log(title = "题库管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('eutr:eq:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisEutrEq bisEutrEq) {
        List<BisEutrEq> list = bisEutrEqService.selectBisEutrEqList(bisEutrEq);
        ExcelUtil<BisEutrEq> util = new ExcelUtil<BisEutrEq>(BisEutrEq.class);
        util.exportExcel(response, list, "题库数据");
    }
}
