package com.ym.mec.biz.dal.dao;

import com.ym.mec.biz.dal.dto.CourseHomeworkStudentDetailDto;
import com.ym.mec.biz.dal.entity.StudentCourseHomework;
import com.ym.mec.common.dal.BaseDAO;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface StudentCourseHomeworkDao extends BaseDAO<Long, StudentCourseHomework> {

    /**
     * @Author: Joburgess
     * @Date: 2019/9/18
     * 统计已提交作业的人数
     */
    @Select("SELECT COUNT(*) FROM student_course_homework WHERE course_homework_id_=#{courseHomeworkID} FOR UPDATE")
    int countCompletedStudentNum(Long courseHomeworkID);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/18
     * 获取学生作业界面详细信息
     */
    CourseHomeworkStudentDetailDto findCourseHomeworkStudentDetail(@Param("courseScheduleID") Long courseScheduleID,
                                                                   @Param("userID") Long userID);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/18
     * 批量插入学生作业提交记录
     */
    int batchInsertStudentCourseHomeworkRecord(List<StudentCourseHomework> studentCourseHomeworks);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/18
     * 构建初始学生作业提交记录
     */
    List<StudentCourseHomework> constructInitialStudentHomeworkRecords(@Param("courseScheduleID") Long courseScheduleID,
                                                                       @Param("courseHomeworkID") Long courseHomeworkID);
	
}