Skip to content

Commit

Permalink
SCRUM-48 fix: TokenRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
yeopyeop-82 committed Aug 12, 2024
1 parent bec4068 commit e017a9c
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@
public interface TokenRepository extends JpaRepository<Token, Long> {

@Query(value = """
select t from Token t inner join User u on t.user.userId = u.userId
where u.userId = :id and (t.expired = false or t.revoked = false)
select t from Token t inner join Buyer u on t.buyer.buyerId = u.buyerId
where u.buyerId = :id and (t.expired = false or t.revoked = false)
""")
List<Token> findAllValidTokenByUser(@Param("id") Long id);
List<Token> findAllValidTokenByBuyer(@Param("id") Long id);

@Query(value = """
select t from Token t inner join Seller u on t.seller.sellerId = u.sellerId
where u.sellerId = :id and (t.expired = false or t.revoked = false)
""")
List<Token> findAllValidTokenBySeller(@Param("id") Long id);

Optional<Token> findByToken(String token);
}

0 comments on commit e017a9c

Please sign in to comment.