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

import java.util.List;

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 cn.com.qmth.stmms.biz.distributpaper.model.CaseLibrary;

public interface CaseLibraryDao extends PagingAndSortingRepository<CaseLibrary, Integer>,
        JpaSpecificationExecutor<CaseLibrary> {

    List<CaseLibrary> findByExamIdAndBlockId(Integer examId, Integer blockId);

    List<CaseLibrary> findByExamIdAndBlockIdAndSubjectCode(Integer examId, Integer blockId, String subjectCode);

    List<CaseLibrary> findByBlockIdAndSecretNo(Integer blockId, Integer secretNo);

    List<CaseLibrary> findByBlockId(Integer blockId);

    @Modifying
    @Query("update CaseLibrary c set c.getCount=c.getCount+1 where c.id=?1")
    void incrGetCount(Integer id);
}
