package com.ruoyi.web.controller.exam;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.exam.dto.ExamDTO;
import com.ruoyi.system.domain.exam.dto.response.ExamOnlineRespDTO;
import com.ruoyi.web.controller.manager.ExamManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * packageName com.ruoyi.web.controller.examination
 *
 * @author wangxy
 * @version JDK 8
 * @className OnlineExam
 * @date 2024/6/28
 * @description 在线考试
 */
@Api("在线考试")
@Controller
@RequestMapping("/system/onlineExam")
public class OnlineExamController extends BaseController {

    @Resource
    private ExamManager examManager;

    private String prefix = "system/elExam/onlineExam";


    @ApiOperation("在线考试")
    @RequiresPermissions("system:onlineExam:view")
    @GetMapping()
    public String onlineExam() {
        return prefix + "/onlineExam";
    }

    @ApiOperation("在线考试")
    //@RequiresPermissions("system:onlineExam:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ExamDTO examDTO) {
        startPage();
        examDTO.setUserId(getUserId());
        List<ExamOnlineRespDTO> list = examManager.onlineExamList(examDTO);
        return getDataTable(list);
    }

    @ApiOperation("去考试")
    @GetMapping("/toExam/{id}")
    public String add(@PathVariable("id") String id, ModelMap mmap) {
        mmap.put("exam",examManager.view(id));
        return prefix + "/toExam";
    }




}
