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.StandardLibrary;

public interface StandardLibraryDao extends PagingAndSortingRepository<StandardLibrary, Integer>,
        JpaSpecificationExecutor<StandardLibrary> {

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

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

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

    List<StandardLibrary> findByBlockId(Integer blockId);

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