package com.ssj.dao.kmt.kmt.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.ssj.bean.kmt.kmt.domain.KmtExerciseQuestionKnow;

import java.util.List;

@Repository
public interface KmtExerciseQuestionKnowDao extends JpaRepository<KmtExerciseQuestionKnow, String> {

    /**
     * 根据题目的id查询关联知识点
     */
    List<KmtExerciseQuestionKnow> findByQuestionId(String questionId);

    /**
     * 根据题目的id集合查询关联知识点
     */
    List<KmtExerciseQuestionKnow> findByQuestionIdIn(List<String> wrongQuestionIdList);

    /**
     * 删除关联的知识点
     * @param questionIds
     */
    @Modifying
    @Query(nativeQuery = true, value = "delete from kmt_exercise_question_know where question_id in (?1)")
    void deleteByQuestionId(List<String> questionIds);
}
