package com.ym.mec.teacher.controller;

import com.ym.mec.biz.dal.dto.TeacherSignOutDto;
import com.ym.mec.biz.dal.entity.StudentAttendance;
import com.ym.mec.biz.dal.page.StudentAttendanceQueryInfo;
import com.ym.mec.biz.dal.page.TeacherAttendanceQueryInfo;
import com.ym.mec.biz.service.StudentAttendanceService;
import com.ym.mec.biz.service.TeacherAttendanceService;
import com.ym.mec.common.controller.BaseController;
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;

@RequestMapping("teacherAttendance")
@Api(tags = "教师签到服务")
@RestController
public class TeacherAttendanceController extends BaseController {

    @Autowired
    private TeacherAttendanceService teacherAttendanceService;

    @Autowired
    private StudentAttendanceService studentAttendanceService;

    @ApiOperation(value = "新增教师签到")
    @PostMapping("/add")
    public Object add(@RequestBody TeacherSignOutDto teacherSignOutDto) {
        return succeed(teacherAttendanceService.addTeacherAttendanceRecord(teacherSignOutDto));
    }

    @ApiOperation(value = "分页查询教师签到列表")
    @GetMapping("/queryPage")
    public Object queryPage(TeacherAttendanceQueryInfo queryInfo) {
        return succeed(teacherAttendanceService.queryPage(queryInfo));
    }

    @ApiOperation(value = "查询教师签到记录")
    @GetMapping("/getTeacherPersonalAttendances")
    public Object getTeacherPersonalAttendances(TeacherAttendanceQueryInfo queryInfo){
        return teacherAttendanceService.getTeacherPersonalAttendances(queryInfo);
    }

    @ApiOperation(value = "根据班级ID获取当前课程的学生")
    @GetMapping("/getCurrentCourseStudents")
    public Object getCurrentCourseStudents(@RequestBody StudentAttendanceQueryInfo queryInfo){
        return succeed(studentAttendanceService.getCurrentCourseStudents(queryInfo));
    }

    @ApiOperation(value = "点名完成")
    @PostMapping("/addStudentAttendances")
    public Object addStudentAttendances(@RequestBody List<StudentAttendance> studentAttendances){
        studentAttendanceService.addStudentAttendances(studentAttendances);
        return succeed();
    }

}
