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

/**
 * 测试学生Controller
 * 
 * @author ruoyi
 * @date 2025-09-18
 */
@RestController
@RequestMapping("/learn/test_student")
@Api("后台-学习 - 批次卷发布")
public class LearnTestStudentController extends BaseController
{
    @Autowired
    private ILearnTestStudentService learnTestStudentService;

    /**
     * 查询测试学生列表
     */
    @PreAuthorize("@ss.hasPermi('learn:test_student:list')")
    @GetMapping("/list")
    public TableDataInfo list(LearnTestStudent learnTestStudent)
    {
        startPage();
        List<LearnTestStudent> list = learnTestStudentService.selectLearnTestStudentList(learnTestStudent);
        return getDataTable(list);
    }

    /**
     * 导出测试学生列表
     */
    @PreAuthorize("@ss.hasPermi('learn:test_student:export')")
    @Log(title = "测试学生", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LearnTestStudent learnTestStudent)
    {
        List<LearnTestStudent> list = learnTestStudentService.selectLearnTestStudentList(learnTestStudent);
        ExcelUtil<LearnTestStudent> util = new ExcelUtil<LearnTestStudent>(LearnTestStudent.class);
        util.exportExcel(response, list, "测试学生数据");
    }

    /**
     * 获取测试学生详细信息
     */
    @PreAuthorize("@ss.hasPermi('learn:test_student:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(learnTestStudentService.selectLearnTestStudentById(id));
    }

    /**
     * 新增测试学生
     */
    @PreAuthorize("@ss.hasPermi('learn:test_student:add')")
    @Log(title = "测试学生", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LearnTestStudent learnTestStudent)
    {
        return toAjax(learnTestStudentService.insertLearnTestStudent(learnTestStudent));
    }

    /**
     * 修改测试学生
     */
    @PreAuthorize("@ss.hasPermi('learn:test_student:edit')")
    @Log(title = "测试学生", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LearnTestStudent learnTestStudent)
    {
        return toAjax(learnTestStudentService.updateLearnTestStudent(learnTestStudent));
    }

    /**
     * 删除测试学生
     */
    @PreAuthorize("@ss.hasPermi('learn:test_student:remove')")
    @Log(title = "测试学生", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(learnTestStudentService.deleteLearnTestStudentByIds(ids));
    }
}
