package cn.com.qmth.stmms.biz.exam.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.exam.model.MarkerClass;

public interface MarkerClassDao extends PagingAndSortingRepository<MarkerClass, Integer>,
        JpaSpecificationExecutor<MarkerClass> {

    List<MarkerClass> findByUserIdAndExamId(int userId, int examId);

    @Query("select count(s) from MarkerClass s where s.userId=?1 and s.examId=?2 ")
    public long countByUserIdAndExamId(int userId, int examId);

    @Modifying
    @Query("delete MarkerClass c where c.userId=?1 and c.examId=?2 ")
    void deleteByUserIdAndExamId(int userId, int examId);

    MarkerClass findByUserIdAndExamIdAndClassName(Integer userId, Integer examId, String className);

}
