package com.ruoyi.model.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.model.domain.AppletQuestion;
import com.ruoyi.model.service.IAppletQuestionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考核题库Controller
 * 
 * @author ruoyi
 * @date 2025-03-28
 */
@RestController
@RequestMapping("/model/AppletQuestion")
public class AppletQuestionController extends BaseController
{
    @Autowired
    private IAppletQuestionService appletQuestionService;

    /**
     * 查询考核题库列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppletQuestion:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppletQuestion appletQuestion)
    {
        startPage();
        List<AppletQuestion> list = appletQuestionService.selectAppletQuestionList(appletQuestion);
        return getDataTable(list);
    }

    /**
     * 导出考核题库列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppletQuestion:export')")
    @Log(title = "考核题库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppletQuestion appletQuestion)
    {
//        List<AppletQuestion> list = appletQuestionService.selectAppletQuestionList(appletQuestion);
//        ExcelUtil<AppletQuestion> util = new ExcelUtil<AppletQuestion>(AppletQuestion.class);
//        util.exportExcel(response, list, "考核题库数据");
    }

    /**
     * 获取考核题库详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:AppletQuestion:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appletQuestionService.selectAppletQuestionById(id));
    }

    /**
     * 新增考核题库
     */
    @PreAuthorize("@ss.hasPermi('model:AppletQuestion:add')")
    @Log(title = "考核题库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppletQuestion appletQuestion)
    {
        return toAjax(appletQuestionService.insertAppletQuestion(appletQuestion));
    }

    /**
     * 修改考核题库
     */
    @PreAuthorize("@ss.hasPermi('model:AppletQuestion:edit')")
    @Log(title = "考核题库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppletQuestion appletQuestion)
    {
        return toAjax(appletQuestionService.updateAppletQuestion(appletQuestion));
    }

    /**
     * 删除考核题库
     */
    @PreAuthorize("@ss.hasPermi('model:AppletQuestion:remove')")
    @Log(title = "考核题库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appletQuestionService.deleteAppletQuestionByIds(ids));
    }
}
