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


/** 
 * @author  ZhangCaibao 
 * @version 2018年3月21日 上午10:58:54 
 * 类说明 
 */
@Repository
public interface StoryTaskIntegralDao  extends JpaRepository<StoryTaskIntegral, String>{
	
	 @Query(nativeQuery = true, value = " select *   from  tb_story_task_integral  where user_id = ?1 and type = ?2")
	public StoryTaskIntegral findByUserIdAndType(String userId,Integer type);
	 
	 @Query(nativeQuery = true, value = " select *   from  tb_story_task_integral  where user_id = ?1 ")
	 List<StoryTaskIntegral> findByUserId(String userId);
	 @Query(nativeQuery = true, value = " select count(1)  from  tb_story_task_integral  where user_id = ?1 ")
	 public Integer countIntegral(String userId);
	 
	 
	 @Query(nativeQuery = true, value = " select user_id   from  tb_story_task_integral  where type = ?1  order by num desc LIMIT  10")
	 List<String> findByType(Integer type);
}
