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

@RestController
@RequestMapping("/eutr/subjectofcour")
public class BisEutrSubjectOfCourController extends BaseController {
    @Autowired
    private IBisEutrSubjectOfCourService bisEutrSubjectOfCourService;

    @GetMapping("/list")
    public TableDataInfo list(BisEutrSubjectOfCour bisEutrSubjectOfCour) {
        startPage();
        List<BisEutrSubjectOfCour> list = bisEutrSubjectOfCourService.selectBisEutrSubjectOfCourList(bisEutrSubjectOfCour);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisEutrSubjectOfCour bisEutrSubjectOfCour) {
        return toAjax(bisEutrSubjectOfCourService.insertBisEutrSubjectOfCour(bisEutrSubjectOfCour));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisEutrSubjectOfCour bisEutrSubjectOfCour) {
        return toAjax(bisEutrSubjectOfCourService.updateBisEutrSubjectOfCour(bisEutrSubjectOfCour));
    }

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

    @Log(title = "课程科目关联管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('eutr:subjectofcour:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisEutrSubjectOfCour bisEutrSubjectOfCour) {
        List<BisEutrSubjectOfCour> list = bisEutrSubjectOfCourService.selectBisEutrSubjectOfCourList(bisEutrSubjectOfCour);
        ExcelUtil<BisEutrSubjectOfCour> util = new ExcelUtil<BisEutrSubjectOfCour>(BisEutrSubjectOfCour.class);
        util.exportExcel(response, list, "课程科目关联数据");
    }
}
