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

import java.util.List;

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


/** 
 * @author  ZhangCaibao 
 * @version 2018年3月21日 下午2:08:27 
 * 类说明 
 */
@Repository
public interface StoryTaskPracticeDao extends JpaRepository<StoryTaskPractice, String>{
	@Query(nativeQuery = true, value = " select *  from  tb_story_task_practice  where story_task_id=?1 and user_id = ?2")
	StoryTaskPractice findByStoryTaskIdAndUserId(String storyTaskId,String userId);
	
	@Query(nativeQuery = true, value = " select  count(1)  from  tb_story_task_practice  where story_id=?1 and user_id = ?2")
	 public Integer countPractice(String storyId,String userId);
	@Query(nativeQuery = true, value = " select  count(1)  from  tb_story_task_practice  where user_id = ?1")
	public Integer countPractice(String userId);
	 @Query(nativeQuery = true, value ="SELECT  c.days_num  from  tb_story_task_practice c\n" +
			 "where  c.story_id =?1\n" +
			 "and c.user_id =?2\n" +
			 "GROUP BY c.days_num ")
	 public List<Integer> getStoryPracticeDayNum(String storyId,String userId);
}
