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

import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import cn.com.qmth.stmms.biz.exam.model.ObjectiveQuestion;

public interface ObjectiveQuestionDao extends PagingAndSortingRepository<ObjectiveQuestion, Integer> {

    @Query("select q from ObjectiveQuestion q where q.pk.blockId=?1 order by q.pk.number asc")
    public List<ObjectiveQuestion> findByBlockId(int blockId);

    @Query("select q from ObjectiveQuestion q where q.pk.blockId=?1 and q.pk.number=?2")
    public List<ObjectiveQuestion> findByBlockIdAndNumber(int blockId, int number);

    @Modifying
    @Query("delete from ObjectiveQuestion q where q.pk.blockId=?1")
    public void deleteByBlockId(int blockId);
}
