package com.ynfy.buss.exam.question.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ynfy.buss.exam.question.dto.QuestionConditionDTO;
import com.ynfy.buss.exam.question.dto.QuestionDTO;
import com.ynfy.buss.exam.question.entity.Question;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @Description: question
 * @Author: jeecg-boot
 * @Date: 2023-02-22
 * @Version: V1.0
 */
public interface QuestionMapper extends BaseMapper<Question> {

    /**
     * 查询题目和答案
     *
     * @param idList
     * @param needAnswerFlag 是否需要标记答案
     * @param needAnalysis   是否需要解析
     * @return
     */
    List<Question> selectQuestionList(@Param("idList") List<String> idList, @Param("needAnswerFlag") boolean needAnswerFlag
            , @Param("needAnalysis") boolean needAnalysis);

    /**
     * 查询用户的考试题目和答案（此时查询的答案可能是乱序的）
     *
     * @param needAnswerFlag 是否需要标记答案
     * @param needAnalysis   是否需要解析
     * @return
     */
    List<Question> listUserExamQuestionAnswer(@Param("userExamId") String userExamId, @Param("objectiveList") List<String> objectiveList,
                                              @Param("subjectiveList") List<String> subjectiveList,
                                              @Param("needAnswerFlag") boolean needAnswerFlag, @Param("needAnalysis") boolean needAnalysis,
                                              @Param("needPathScore") boolean needPathScore, @Param("needSubjective") boolean needSubjective);

    List<QuestionDTO> groupLevelById(@Param("repositoryIds") List<String> repositoryIds,
                                     @Param("type") Integer type, @Param("questionIds") List<String> questionIds);

    List<Question> listByPaperId(String paperId);


    /**
     * 查询题库，对应的题型数量
     *
     * @param repositoryIds
     * @param type
     * @return
     */
    List<Question> groupCount(@Param("repositoryIds") List<String> repositoryIds, @Param("type") Integer type);


    /**
     * 根据题库，题型，难度的集合获取题目
     *
     * @param dtoList
     * @return
     */
    List<Question> listQuestionByCondition(List<QuestionConditionDTO> dtoList);

    IPage<Question> selectPageList(IPage<Question> page, @Param("question") Question question);


    /**
     * 统计题库题目数量
     *
     * @param repositoryIds
     * @return
     */
    List<QuestionDTO> countQuestionByRepository(@Param("repositoryIds") List<String> repositoryIds);

    /**
     * 计算指定题库的题目题型数量
     *
     * @param repositoryId
     * @return
     */
    List<QuestionDTO> countQuestionNumByType(String repositoryId);


    /**
     * 统计题库、题型的题目数量
     *
     * @param repositoryIds
     * @return
     */
    List<QuestionDTO> countQuestionType(@Param("repositoryIds") List<String> repositoryIds);

}
