package com.ssj.dao.weixin.story.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.weixin.story.bean.StoryAddress;


/** 
 * @author  ZhangCaibao 
 * @version 2018年3月21日 上午10:54:07 
 * 类说明 
 */
@Repository
public interface StoryAddressDao extends JpaRepository<StoryAddress, String>{

	
	@Query(nativeQuery = true, value = " select  count(1)  from  tb_story_address  where user_id=?1 ")
	int integralcount(String userId);

	@Query(nativeQuery = true, value = " select  count(1)  from  tb_story_address  where address=?1 and  type =?2 ")
	int integralAddresscount(String address ,int  type );


	@Query(nativeQuery = true, value = " DELETE from  tb_story_address where  address = ?1 ")
	@Modifying
	void  deleteByAddress(String address);

	@Query(nativeQuery = true, value = " select  *  from  tb_story_address  where user_id=?1 and  type =?2  limit 1")
    StoryAddress findStoryByUserIdAndType(String userId, int type);
}
