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

public interface MarkLevelDao extends PagingAndSortingRepository<MarkLevel, Integer> {

    @Query("select m from MarkLevel m where m.pk.blockId=?1 and m.pk.stepNumber=?2 order by m.pk.number")
    public List<MarkLevel> findByBlockIdAndStepNumber(int blockId, int stepNumber);

    @Query("select m from MarkLevel m where m.pk.blockId=?1 and m.pk.stepNumber=?2 and m.pk.number=?3")
    public List<MarkLevel> findByBlockIdAndStepNumberAndNumber(int blockId, int stepNumber, int levelNumber);

    @Modifying
    @Query("delete from MarkLevel m where m.pk.blockId=?1 and m.pk.stepNumber=?2")
    public void deleteByBlockIdAndStepNumber(int blockId, int stepNumber);

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