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

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import cn.com.qmth.stmms.biz.mark.model.RejectHistory;

public interface RejectHistoryDao extends JpaRepository<RejectHistory, Integer>,
        JpaSpecificationExecutor<RejectHistory> {

    @Modifying
    @Query("delete RejectHistory m where m.studentId=?1")
    void deleteByStudentId(Integer studentId);

    @Modifying
    @Query("delete from RejectHistory s where s.examId=?1 and s.subjectCode=?2 and s.groupNumber=?3  ")
    void deleteByExamIdAndSubjectCodeAndGroupNumber(Integer examId, String subjectCode, Integer groupNumber);

    List<RejectHistory> findByLibraryIdOrderByIdDesc(Integer libraryId);

    @Query("select distinct s.userId from RejectHistory s where s.examId=?1 and s.subjectCode=?2")
    List<Integer> getUserIdByExamIdAndSubjectCode(Integer examId, String subjectCode);

}
