package com.ruoyi.web.controller.learn;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
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.learn.domain.LearnPaperReal;
import com.ruoyi.learn.service.ILearnPaperRealService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 真题卷Controller
 * 
 * @author ruoyi
 * @date 2025-09-18
 */
@RestController
@RequestMapping("/learn/paper_real")
@Api("后台-学习 - 真题")
public class LearnPaperRealController extends BaseController
{
    @Autowired
    private ILearnPaperRealService learnPaperRealService;

    /**
     * 查询真题卷列表
     */
    @PreAuthorize("@ss.hasPermi('learn:paper_real:list')")
    @GetMapping("/list")
    public TableDataInfo list(LearnPaperReal learnPaperReal)
    {
        startPage();
        List<LearnPaperReal> list = learnPaperRealService.selectLearnPaperRealList(learnPaperReal);
        return getDataTable(list);
    }

    /**
     * 导出真题卷列表
     */
    @PreAuthorize("@ss.hasPermi('learn:paper_real:export')")
    @Log(title = "真题卷", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LearnPaperReal learnPaperReal)
    {
        List<LearnPaperReal> list = learnPaperRealService.selectLearnPaperRealList(learnPaperReal);
        ExcelUtil<LearnPaperReal> util = new ExcelUtil<LearnPaperReal>(LearnPaperReal.class);
        util.exportExcel(response, list, "真题卷数据");
    }

    /**
     * 获取真题卷详细信息
     */
    @PreAuthorize("@ss.hasPermi('learn:paper_real:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(learnPaperRealService.selectLearnPaperRealById(id));
    }

    /**
     * 新增真题卷
     */
    @PreAuthorize("@ss.hasPermi('learn:paper_real:add')")
    @Log(title = "真题卷", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LearnPaperReal learnPaperReal)
    {
        return toAjax(learnPaperRealService.insertLearnPaperReal(learnPaperReal));
    }

    /**
     * 修改真题卷
     */
    @PreAuthorize("@ss.hasPermi('learn:paper_real:edit')")
    @Log(title = "真题卷", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LearnPaperReal learnPaperReal)
    {
        return toAjax(learnPaperRealService.updateLearnPaperReal(learnPaperReal));
    }

    /**
     * 删除真题卷
     */
    @PreAuthorize("@ss.hasPermi('learn:paper_real:remove')")
    @Log(title = "真题卷", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(learnPaperRealService.deleteLearnPaperRealByIds(ids));
    }
}
