package org.ros.chatto.repository;

import org.ros.chatto.model.UserToken;
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 TokenRepository extends JpaRepository<UserToken, Long> {

	@Query("select t from UserToken t where t.tokenContent = ?1")
	public UserToken findByToken(String token);

	@Query("select t from UserToken t where t.userName = ?1")
	public UserToken findByUserName(String userName);

	@Modifying
	@Query("delete from UserToken t where t.userName = ?1")
	public void deleteByUserName(String userName);
}
