package com.cirle.scientific.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 org.springframework.stereotype.Repository;

import com.cirle.scientific.po.QkjQuestionAnswer;

@Repository
public interface QkjQuestionAnswerDao extends PagingAndSortingRepository<QkjQuestionAnswer, Long>, JpaSpecificationExecutor<QkjQuestionAnswer> {
	
	List<QkjQuestionAnswer> findByMemCardAndObjTypeAndObjId(String memCard, Integer objType, Integer objId);
	
	@Modifying
	@Query(value = "delete from qkj_question_answer where mem_card = ?1 and obj_type=?2 and obj_id=?3", nativeQuery = true)
	void deleteByMemberAndObjTypeAndOjbId(String memCard, Integer objType, Integer objId);

	@Modifying
	@Query(value = "delete from qkj_question_answer where mem_card = ?1 and obj_type=?2 and obj_id=?3 and record_id=?4", nativeQuery = true)
	void deleteByMemberAndObjTypeAndOjbIdAndRecordId(String memCard, Integer objType, Integer objId, Integer recordId);

	@Query(value = "SELECT a.* FROM qkj_question_answer a WHERE a.mem_card=?1 and a.obj_type=2 and a.obj_id=?2 and a.record_id=?3",nativeQuery = true)
	List<QkjQuestionAnswer> findConferPeopleAttribute(String memCard,Integer conferId, Integer recordId);


	@Query(value = "SELECT a.* FROM qkj_question_answer a WHERE  mem_card = ?1 and obj_type=?2 and obj_id=?3", nativeQuery = true)
	List<QkjQuestionAnswer> findByCardAndTypeAndId(String memCard, Integer objType, Integer objId);
}
