package cn.com.qmth.examcloud.core.questions.service;

import cn.com.qmth.examcloud.api.commons.security.bean.User;
import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
import cn.com.qmth.examcloud.core.questions.dao.entity.Paper;
import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetail;
import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailUnit;
import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperDetailUnitExp;

import java.util.List;

/**
 * @author chenken
 * @date 2017年9月13日 上午11:32:00
 * @company QMTH
 * @description PaperDetailUnitService.java
 */
public interface PaperDetailUnitService {

    /**
     * 根据Id获得对应的试题对象
     *
     * @param id
     * @return
     */
    public Question getQuestionByPaperDetailUnitId(String id);

    /**
     * 按ID查询小题
     *
     * @param id
     * @return
     */
    public PaperDetailUnit findById(String id);

    /**
     * 保存小题
     *
     * @param pduExp
     * @return
     */
    public PaperDetailUnit savePaperDetailUnit(PaperDetailUnitExp pduExp, User user);

    /**
     * 删除小题
     *
     * @param id
     * @return
     */
    public void deletePaperDetailUnit(String id, User user);

    /**
     * 根据大题查小题
     *
     * @param paperDetail
     * @return
     */
    public List<PaperDetailUnit> getUnitsByPaperDetail(PaperDetail paperDetail);

    /**
     * 根据大题集合删除小题
     *
     * @param paperDetails
     */
    public void deleteUnitsByPaperDetails(List<PaperDetail> paperDetails);

    public List<PaperDetailUnit> findByQuestionAndPaperTypes(Question question, List<PaperType> paperTypes);

    /**
     * 查询大题下的小题
     * 按number升序或降序排列，取第一个
     *
     * @return
     */
    public PaperDetailUnit findTopOrderByNumber(PaperDetail paperDetail, String orderType);

    /**
     * 按试卷 查询 小题，并将小题按number，createTime排序
     *
     * @param paper
     * @return
     */
    public List<PaperDetailUnit> findByPaperAndSort(Paper paper);

    /**
     * 根据试题id集合和试卷类型查询
     *
     * @param ids
     * @param paperType
     * @return
     */
    public List<PaperDetailUnit> findByQuestionsAndPaperType(List<String> ids, PaperType paperType);

    public List<PaperDetailUnit> findByDDQuestionsAndPaperType(List<String> ids, PaperType paperType, List<Question> questionList);

    //public List<PaperDetailUnit> testFind(List<String> ids,PaperType paperType,List<Question> questionList);

    public List<PaperDetailUnit> findByPaperIds(List<String> ids);

    public void clearQuestionCache(String questionId);

	boolean paperInUse(String questionId);
}
