package com.ssj.dao.weixin.user.dao;

import com.ssj.bean.weixin.user.domain.UserIntegral;
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 java.math.BigDecimal;


@Repository
public interface UserIntegralDao extends JpaRepository<UserIntegral, String> {
	
	public  UserIntegral findByUserId(String userId);
	
	
	@Query(nativeQuery = true, value = "insert into tb_user_integral_log ( id, head, content, integral, user_id) values ( ?5, ?2 , ?3, ?4 ,?1 )  ")
	@Modifying
	public  void  insertIntegralLog(String userId,String  head, String  content,BigDecimal  integral,String id);
	
	@Query(nativeQuery = true, value = " update tb_user_integral set integral=0 ,in_integral =0 ,ex_integral =0, type =0 ")
	@Modifying
	public void emptyPoints();
	
	
	
	

}
