package cn.com.qmth.stmms.biz.report.dao;

import cn.com.qmth.stmms.biz.report.model.ReportSubjectQuestion;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

/**
 * 客、主观题分析 Dao
 *
 * @author xuwenjin
 * @date 2019-04-17
 */
public interface ReportSubjectQuestionDao extends PagingAndSortingRepository<ReportSubjectQuestion, Integer>,
        JpaSpecificationExecutor<ReportSubjectQuestion> {

    @Modifying
    @Query("delete from ReportSubjectQuestion r where r.examId=?1 ")
    void deleteByExamId(Integer exmaId);

    List<ReportSubjectQuestion> findByExamIdAndSubjectCodeAndObjectiveAndPaperType(Integer examId, String subjectCode,
            boolean objective, String paperType, Sort sort);

    @Modifying
    @Query("delete from ReportSubjectQuestion r where r.examId=?1 and r.subjectCode=?2")
    void deleteByExamIdAndSubjectCode(Integer examId, String subjectCode);
}
