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

@RestController
@RequestMapping("/eutr/courcate")
public class BisEutrCourCateController extends BaseController {
    @Autowired
    private IBisEutrCourCateService bisEutrCourCateService;

    @GetMapping("/list")
    public TableDataInfo list(BisEutrCourCate bisEutrCourCate) {
        startPage();
        List<BisEutrCourCate> list = bisEutrCourCateService.selectBisEutrCourCateList(bisEutrCourCate);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisEutrCourCate bisEutrCourCate) {
        return toAjax(bisEutrCourCateService.insertBisEutrCourCate(bisEutrCourCate));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisEutrCourCate bisEutrCourCate) {
        return toAjax(bisEutrCourCateService.updateBisEutrCourCate(bisEutrCourCate));
    }

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

    @Log(title = "培训课程类别管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('eutr:courcate:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisEutrCourCate bisEutrCourCate) {
        List<BisEutrCourCate> list = bisEutrCourCateService.selectBisEutrCourCateList(bisEutrCourCate);
        ExcelUtil<BisEutrCourCate> util = new ExcelUtil<BisEutrCourCate>(BisEutrCourCate.class);
        util.exportExcel(response, list, "培训课程类别数据");
    }
}
