package com.ruoyi.sim.controller;

import java.util.List;

import com.ruoyi.sim.service.impl.RealExamCompRequestService;
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.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.sim.domain.RealExamCompRequest;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考试更换件关联Controller
 *
 * @author tom
 * @date 2024-12-15
 */
@RestController
@RequestMapping("/sim/real-exam-comp-request")
public class RealExamCompRequestController extends BaseController {
    @Autowired
    private RealExamCompRequestService realExamCompRequestService;

    /**
     * [学员]查询考试更换件列表
     */
    @GetMapping("/student/list/{examId}")
    public TableDataInfo listByStudent(Long examId) {
        return realExamCompRequestService.listByStudent(examId);
    }

    /**
     * [教师]查询考试更换件列表
     */
    @GetMapping("/teacher/list/{examCollectionId}")
    public TableDataInfo listByTeacher(Long examCollectionId) {
        startPage();
        List<RealExamCompRequest> list = realExamCompRequestService.listByTeacher(examCollectionId);
        return getDataTable(list);
    }

    /**
     * [学生]新增考试更换件
     */
    @PostMapping("/student")
    public AjaxResult addByStudent(@RequestBody RealExamCompRequest realExamCompRequest) {
        return realExamCompRequestService.addByStudent(realExamCompRequest);
    }

    /**
     * [学生]删除考试更换件
     */
    @DeleteMapping("/student/{relIds}")
    public AjaxResult removeByStudent(@PathVariable Long[] relIds) {
        return realExamCompRequestService.deleteByStudent(relIds);
    }

    /**
     * [教师]已送考试更换件
     */
    @PutMapping("/teacher/sended/{relIds}")
    public AjaxResult updateSended(@PathVariable Long[] relIds) {
        return realExamCompRequestService.updateSendedByTeacher(relIds);
    }

    /**
     * [教师]驳回考试更换件
     */
    @PutMapping("/teacher/turndown/{relIds}")
    public AjaxResult updateTurnDown(@PathVariable Long[] relIds) {
        return realExamCompRequestService.updateTurnDownByTeacher(relIds);
    }
}
