package com.fs.course.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.course.domain.FsCourseQuestionCategory;
import com.fs.course.service.IFsCourseQuestionCategoryService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 题目分类Controller
 *
 * @author fs
 * @date 2025-04-17
 */
@RestController
@RequestMapping("/course/courseQuestionCategory")
public class FsCourseQuestionCategoryController extends BaseController
{
    @Autowired
    private IFsCourseQuestionCategoryService fsCourseQuestionCategoryService;

    /**
     * 查询题目分类列表
     */
    @PreAuthorize("@ss.hasPermi('course:courseQuestionCategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsCourseQuestionCategory fsCourseQuestionCategory)
    {
        startPage();
        List<FsCourseQuestionCategory> list = fsCourseQuestionCategoryService.selectFsCourseQuestionCategoryList(fsCourseQuestionCategory);
        return getDataTable(list);
    }

    /**
     * 导出题目分类列表
     */
    @PreAuthorize("@ss.hasPermi('course:courseQuestionCategory:export')")
    @Log(title = "题目分类", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsCourseQuestionCategory fsCourseQuestionCategory)
    {
        List<FsCourseQuestionCategory> list = fsCourseQuestionCategoryService.selectFsCourseQuestionCategoryList(fsCourseQuestionCategory);
        ExcelUtil<FsCourseQuestionCategory> util = new ExcelUtil<FsCourseQuestionCategory>(FsCourseQuestionCategory.class);
        return util.exportExcel(list, "题目分类数据");
    }

    /**
     * 获取题目分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:courseQuestionCategory:query')")
    @GetMapping(value = "/{cateId}")
    public AjaxResult getInfo(@PathVariable("cateId") Long cateId)
    {
        return AjaxResult.success(fsCourseQuestionCategoryService.selectFsCourseQuestionCategoryByCateId(cateId));
    }

    /**
     * 新增题目分类
     */
    @PreAuthorize("@ss.hasPermi('course:courseQuestionCategory:add')")
    @Log(title = "题目分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsCourseQuestionCategory fsCourseQuestionCategory)
    {
        return toAjax(fsCourseQuestionCategoryService.insertFsCourseQuestionCategory(fsCourseQuestionCategory));
    }

    /**
     * 修改题目分类
     */
    @PreAuthorize("@ss.hasPermi('course:courseQuestionCategory:edit')")
    @Log(title = "题目分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsCourseQuestionCategory fsCourseQuestionCategory)
    {
        return toAjax(fsCourseQuestionCategoryService.updateFsCourseQuestionCategory(fsCourseQuestionCategory));
    }

    /**
     * 删除题目分类
     */
    @PreAuthorize("@ss.hasPermi('course:courseQuestionCategory:remove')")
    @Log(title = "题目分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cateIds}")
    public AjaxResult remove(@PathVariable Long[] cateIds)
    {
        return toAjax(fsCourseQuestionCategoryService.deleteFsCourseQuestionCategoryByCateIds(cateIds));
    }
}
