package com.ruoyi.web.controller.learn;

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.learn.domain.LearnWrongDetail;
import com.ruoyi.learn.service.ILearnWrongDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生错题流水Controller
 * 
 * @author ruoyi
 * @date 2025-09-25
 */
@RestController
@RequestMapping("/learn/WrongDetail")
public class LearnWrongDetailController extends BaseController
{
    @Autowired
    private ILearnWrongDetailService learnWrongDetailService;

    /**
     * 查询学生错题流水列表
     */
    @PreAuthorize("@ss.hasPermi('learn:WrongDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(LearnWrongDetail learnWrongDetail)
    {
        startPage();
        List<LearnWrongDetail> list = learnWrongDetailService.selectLearnWrongDetailList(learnWrongDetail);
        return getDataTable(list);
    }

    /**
     * 导出学生错题流水列表
     */
    @PreAuthorize("@ss.hasPermi('learn:WrongDetail:export')")
    @Log(title = "学生错题流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LearnWrongDetail learnWrongDetail)
    {
        List<LearnWrongDetail> list = learnWrongDetailService.selectLearnWrongDetailList(learnWrongDetail);
        ExcelUtil<LearnWrongDetail> util = new ExcelUtil<LearnWrongDetail>(LearnWrongDetail.class);
        util.exportExcel(response, list, "学生错题流水数据");
    }

    /**
     * 获取学生错题流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('learn:WrongDetail:query')")
    @GetMapping(value = "/{wrongDetailId}")
    public AjaxResult getInfo(@PathVariable("wrongDetailId") Long wrongDetailId)
    {
        return success(learnWrongDetailService.selectLearnWrongDetailByWrongDetailId(wrongDetailId));
    }

    /**
     * 新增学生错题流水
     */
    @PreAuthorize("@ss.hasPermi('learn:WrongDetail:add')")
    @Log(title = "学生错题流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LearnWrongDetail learnWrongDetail)
    {
        return toAjax(learnWrongDetailService.insertLearnWrongDetail(learnWrongDetail));
    }

    /**
     * 修改学生错题流水
     */
    @PreAuthorize("@ss.hasPermi('learn:WrongDetail:edit')")
    @Log(title = "学生错题流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LearnWrongDetail learnWrongDetail)
    {
        return toAjax(learnWrongDetailService.updateLearnWrongDetail(learnWrongDetail));
    }

    /**
     * 删除学生错题流水
     */
    @PreAuthorize("@ss.hasPermi('learn:WrongDetail:remove')")
    @Log(title = "学生错题流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wrongDetailIds}")
    public AjaxResult remove(@PathVariable Long[] wrongDetailIds)
    {
        return toAjax(learnWrongDetailService.deleteLearnWrongDetailByWrongDetailIds(wrongDetailIds));
    }
}
