package com.example.demo.controller.wx;

import com.example.demo.dto.request.exam.ScoreRequest;
import com.example.demo.dto.request.exam.StemAndExamRequest;
import com.example.demo.dto.response.ExamDto;
import com.example.demo.dto.response.ScoreDto;
import com.example.demo.service.ExamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author hxh
 * @Date 2020-09-16 1:22
 * @Descrption TODO
 */
@Api(tags = "考试管理")
@RequestMapping("/wx/exam")
@RestController
public class ExamController {

    @Autowired
    private ExamService examService;

    @ApiOperation(value = "提交年级学科查看试卷（可有多套试卷）")
    @PostMapping("/list")
    public List<ExamDto> list(@RequestBody StemAndExamRequest request){
        return examService.getExamListByGradeAndSubject(request);
    }

    @ApiOperation(value = "提交试卷id查看试卷（仅一套）")
    @GetMapping("/{id}")
    public ExamDto getById(@PathVariable("id") int id){
        return examService.getExamById(id);
    }

    @ApiOperation(value = "提交试卷id和书写答案来查看得分和正确答案（系统从下标0开始判断）")
    @PostMapping("/score")
    public ScoreDto getScore(@RequestBody ScoreRequest request){
        return examService.getScore(request);
    }

}
