package com.ssj.dao.sys.schoolmatecircle.dao;

import com.ssj.bean.sys.schoolmatecircle.domain.SSJUserFriend;
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;

@Repository
public interface SSJUserFriendDao extends JpaRepository<SSJUserFriend, String> {

	@Query(nativeQuery = true, value = "delete from ssj_user_friend where (owner_user_id = ?1 and friend_user_id = ?2) or (owner_user_id = ?2 and friend_user_id = ?1)")
	@Modifying
	public void deleteFriend(String userId,String friendUserId);
	
	@Query(nativeQuery = true, value = "select count(*) from ssj_user_friend where (owner_user_id = ?1 and friend_user_id = ?2) or (owner_user_id = ?2 and friend_user_id = ?1)")
	public int validateIsFriend(String userId,String friendUserId);

	@Modifying
	@Query(nativeQuery = true,value = "delete from ssj_user_friend where (owner_user_id = ?1 or friend_user_id = ?1)")
	public void deleteFriends(String userId);
}
