package com.ssj.dao.weixin.story.dao;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.ssj.bean.weixin.story.bean.StoryTaskTopic;


/** 
 * @author  ZhangCaibao 
 * @version 2018年3月21日 上午11:01:50 
 * 类说明 
 */
@Repository
public interface StoryTaskTopicDao extends JpaRepository<StoryTaskTopic, String>{
	
	 public Page<StoryTaskTopic> findAll(Specification<StoryTaskTopic> specification, Pageable page);

	@Query(nativeQuery = true, value =" SELECT   *  from  tb_story_task_topic  where  story_task_id =?1 ")
	List<StoryTaskTopic> findByStoryTaskId(String storyTaskId);
	
	@Query(nativeQuery = true, value ="SELECT   *  from  tb_story_task_topic  \n" +
			"where type =?1\n" +
			"order by rand() limit 1")
	StoryTaskTopic randomTopic(int type);
	
	
}
