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

import cn.com.qmth.stmms.biz.exam.model.SubjectUser;
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 java.util.List;

public interface SubjectUserDao extends PagingAndSortingRepository<SubjectUser, Integer>,
        JpaSpecificationExecutor<SubjectUser> {

    List<SubjectUser> findByUserId(Integer userId);

    SubjectUser findBySubjectCodeAndUserId(String subjectCode, Integer userId);

    @Modifying
    @Query("delete from SubjectUser su where su.userId=?1")
    void deleteByUserId(Integer userId);
}
