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

@RestController
@RequestMapping("/eutr/tqueopt")
public class BisEutrTqueOptController extends BaseController {
    @Autowired
    private IBisEutrTqueOptService bisEutrTqueOptService;

    @GetMapping("/list")
    public TableDataInfo list(BisEutrTqueOpt bisEutrTqueOpt) {
        startPage();
        List<BisEutrTqueOpt> list = bisEutrTqueOptService.selectBisEutrTqueOptList(bisEutrTqueOpt);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisEutrTqueOpt bisEutrTqueOpt) {
        return toAjax(bisEutrTqueOptService.insertBisEutrTqueOpt(bisEutrTqueOpt));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisEutrTqueOpt bisEutrTqueOpt) {
        return toAjax(bisEutrTqueOptService.updateBisEutrTqueOpt(bisEutrTqueOpt));
    }

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

    @Log(title = "题目选项管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('eutr:tqueopt:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisEutrTqueOpt bisEutrTqueOpt) {
        List<BisEutrTqueOpt> list = bisEutrTqueOptService.selectBisEutrTqueOptList(bisEutrTqueOpt);
        ExcelUtil<BisEutrTqueOpt> util = new ExcelUtil<BisEutrTqueOpt>(BisEutrTqueOpt.class);
        util.exportExcel(response, list, "题目选项数据");
    }
}
