package com.keao.edu.controller;

import com.keao.edu.common.controller.BaseController;
import com.keao.edu.common.entity.HttpResponseResult;
import com.keao.edu.user.dto.StuRecordDetailDto;
import com.keao.edu.user.service.ExamRoomStudentRelationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("examRoomStudentRelation")
@Api(tags = "考场与学生关联服务")
public class ExamRoomStudentRelationController extends BaseController {

    @Autowired
    private ExamRoomStudentRelationService examRoomStudentRelationService;

    @ApiOperation("签到")
    @PostMapping(value = "/signIn")
    public HttpResponseResult signIn(Long examRegistrationId) {
        examRoomStudentRelationService.signIn(examRegistrationId);
        return succeed();
    }

    @ApiOperation("学生端录播详情页面")
    @GetMapping(value = "/stuRecordDetail")
    public HttpResponseResult<StuRecordDetailDto> stuRecordDetail(Long examRegistrationId) {
        return succeed(examRoomStudentRelationService.stuRecordDetail(examRegistrationId));
    }

    @ApiOperation("学生端完成录播")
    @PostMapping(value = "/stuEndRecord")
    public HttpResponseResult stuEndRecord(Long examRegistrationId,String videoUrl) {
        examRoomStudentRelationService.stuEndRecord(examRegistrationId,videoUrl);
        return succeed();
    }

}
