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

import cn.com.qmth.stmms.biz.report.model.ReportSubjectGroup;
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-18
 */
public interface ReportSubjectGroupDao
        extends PagingAndSortingRepository<ReportSubjectGroup, Integer>, JpaSpecificationExecutor<ReportSubjectGroup> {

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

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

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