package com.ruoyi.web.controller.system.count;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TdExamnum;
import com.ruoyi.system.service.ITdExamnumService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

import javax.servlet.http.HttpServletRequest;

/**
 * 考试结果Controller
 * 
 * @author ruoyi
 * @date 2024-04-10
 */
@Controller
@RequestMapping("/system/examnum")
public class TdExamnumController extends BaseController
{
    private String prefix = "system/examnum";

    @Autowired
    private ITdExamnumService tdExamnumService;

    @RequiresPermissions("system:examnum:view")
    @GetMapping()
    public String examnum()
    {
        return prefix + "/examnum";
    }

    /**
     * 查询考试结果列表
     */
    @RequiresPermissions("system:examnum:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TdExamnum tdExamnum)
    {
        startPage();
        List<TdExamnum> list = tdExamnumService.selectTdExamnumList(tdExamnum);
        return getDataTable(list);
    }

    /**
     * 导出考试结果列表
     */
    @RequiresPermissions("system:examnum:export")
    @Log(title = "考试结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TdExamnum tdExamnum)
    {
        List<TdExamnum> list = tdExamnumService.selectTdExamnumList(tdExamnum);
        ExcelUtil<TdExamnum> util = new ExcelUtil<TdExamnum>(TdExamnum.class);
        return util.exportExcel(list, "考试结果数据");
    }

    /**
     * 新增考试结果
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存考试结果
     */
    @RequiresPermissions("system:examnum:add")
    @Log(title = "考试结果", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TdExamnum tdExamnum)
    {
        return toAjax(tdExamnumService.insertTdExamnum(tdExamnum));
    }

    /**
     * 修改考试结果
     */
    @RequiresPermissions("system:examnum:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TdExamnum tdExamnum = tdExamnumService.selectTdExamnumById(id);
        mmap.put("tdExamnum", tdExamnum);
        return prefix + "/edit";
    }

    /**
     * 修改保存考试结果
     */
    @RequiresPermissions("system:examnum:edit")
    @Log(title = "考试结果", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TdExamnum tdExamnum)
    {
        return toAjax(tdExamnumService.updateTdExamnum(tdExamnum));
    }

    /**
     * 删除考试结果
     */
    @RequiresPermissions("system:examnum:remove")
    @Log(title = "考试结果", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tdExamnumService.deleteTdExamnumByIds(ids));
    }


}
