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.MarkTrack;
import cn.com.qmth.stmms.biz.mark.model.MarkTrackPK;

public interface MarkTrackDao extends JpaRepository<MarkTrack, MarkTrackPK>, JpaSpecificationExecutor<MarkTrack> {

    List<MarkTrack> findByPkStudentId(Integer studentId);

    @Modifying
    @Query("delete from MarkTrack t where t.pk.studentId=?1")
    void deleteByStudentId(Integer studentId);

    @Modifying
    @Query("delete from MarkTrack t where t.pk.studentId=?1 and t.pk.questionNumber=?2")
    void deleteByStudentIdAndQuestionNumber(Integer studentId, String questionNumber);

    @Modifying
    @Query("delete from MarkTrack t where t.examId=?1")
    void deleteByExamId(Integer examId);

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

    @Modifying
    @Query("delete from MarkTrack t where t.markerId=?1")
    void deleteByMarkerId(Integer markerId);

}
