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

import cn.com.qmth.stmms.biz.report.model.ReportSubjectClassGroup;
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;

public interface ReportSubjectClassGroupDao extends PagingAndSortingRepository<ReportSubjectClassGroup, Integer>,
        JpaSpecificationExecutor<ReportSubjectClassGroup> {

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

    List<ReportSubjectClassGroup> findByExamIdAndSubjectCodeAndObjectiveAndPaperTypeAndClassName(Integer examId,
            String subjectCode, boolean objective, String paperType, String className, Sort sort);

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