package com.keao.edu.user.dao;

import com.keao.edu.common.dal.BaseDAO;
import com.keao.edu.user.api.enums.StudentExamResultApiDto;
import com.keao.edu.user.dto.StudentExamResultStatisticsDto;
import com.keao.edu.user.entity.StudentExamResult;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

public interface StudentExamResultDao extends BaseDAO<Long, StudentExamResult> {

    int batchInsert(@Param("results") List<StudentExamResult> results);

    int deleteWithRegists(@Param("registIds") List<Long> registIds);

    /**
     * @describe 获取指定考级项目的考级结果
     * @author Joburgess
     * @date 2020.07.24
     * @param examId:
     * @return java.util.List<com.keao.edu.user.entity.StudentExamResult>
     */
    List<StudentExamResult> getWithExam(@Param("examId") Long examId);

    /**
     * @describe 查询考试结果
     * @author Joburgess
     * @date 2020.06.30
     * @param params:
     * @return java.util.List<com.keao.edu.user.entity.StudentExamResult>
     */
    List<StudentExamResult> queryStudentExamResult(Map<String, Object> params);

    int countStudentExamResult(Map<String, Object> params);

    /**
     * @describe 考试结果统计信息
     * @author Joburgess
     * @date 2020.06.30
     * @param organIds:
     * @param examId:
     * @return com.keao.edu.user.dto.StudentExamResultStatisticsDto
     */
    StudentExamResultStatisticsDto getStudentExamResultStatisticsInfo(@Param("organIds") List<Integer> organIds,
                                                                      @Param("examId") Integer examId);

    /**
     * 获取考试次数
     * @param studentIds
     * @param tenantId
     * @return
     */
    List<Map<Integer, Integer>> countExamNum(@Param("studentIds") List<Integer> studentIds, @Param("tenantId") String tenantId);

    /**
     * 获取考试结果
     * @param examRegistrationId
     * @return
     */
    StudentExamResult findByRegistrationId(Long examRegistrationId);

    /**
     * 获取考试结果
     * @param examRegistrationId
     * @return
     */
    StudentExamResultApiDto getStudentExamResultApiDto(Long examRegistrationId);

    /**
     * 确认考生
     * @param examRegistrationId
     */
    void confirmStudent(Long examRegistrationId);

    /**
     * 修改学员考试状态
     * @param examRegistrationId
     * @param finishedExam
     */
    void updateFinishedExam(@Param("examRegistrationId") Long examRegistrationId, @Param("finishedExam") Integer finishedExam);

    /**
     * 获取学员房间关联
     * @param roomId
     * @param userId
     */
    StudentExamResult findByRoomIdAndUserId(@Param("roomId") String roomId, @Param("userId") String userId);

    /**
     * @describe 批量修改考试结果
     * @author Joburgess
     * @date 2020.07.30
     * @param results:
     * @return int
     */
    int updateRegistAvgScore(@Param("results") List<StudentExamResult> results);

    /**
     * @describe 获取指定考场的学员考试结果
     * @author Joburgess
     * @date 2020.08.03
     * @param examRoomId:
     * @return java.util.List<com.keao.edu.user.entity.StudentExamResult>
     */
    List<StudentExamResult> getWithExamRoom(@Param("examRoomId") Long examRoomId);

    /**
     * @describe 统计考级项目下未确认结果的学生数量
     * @author Joburgess
     * @date 2020.08.03
     * @param examId:
     * @return int
     */
    int countExamNoResultStudentNum(@Param("examId") Long examId);
}
