-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
좋아요 조회 및 업데이트 버그 수정
- Loading branch information
Showing
18 changed files
with
452 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
backend/src/main/java/hanglog/like/domain/LikeRedisConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package hanglog.like.domain; | ||
|
||
import java.time.Duration; | ||
|
||
public class LikeRedisConstants { | ||
|
||
public static final String LIKE_KEY_PREFIX = "like:"; | ||
public static final String WILD_CARD = "*"; | ||
public static final String KEY_SEPARATOR = ":"; | ||
public static final Long EMPTY_MARKER = -1L; | ||
public static final Duration LIKE_TTL = Duration.ofMinutes(90L); | ||
|
||
public static String generateLikeKey(final Long tripId) { | ||
return LIKE_KEY_PREFIX + tripId; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
backend/src/main/java/hanglog/like/domain/repository/CustomLikeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
package hanglog.like.domain.repository; | ||
|
||
import hanglog.like.domain.Likes; | ||
import hanglog.like.dto.LikeElement; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface CustomLikeRepository { | ||
|
||
void saveAll(final List<Likes> likes); | ||
|
||
Optional<LikeElement> findLikesElementByTripId(final Long tripId); | ||
|
||
List<LikeElement> findLikeElementByTripIds(final List<Long> tripIds); | ||
} |
10 changes: 0 additions & 10 deletions
10
backend/src/main/java/hanglog/like/domain/repository/LikeCountRepository.java
This file was deleted.
Oops, something went wrong.
36 changes: 5 additions & 31 deletions
36
backend/src/main/java/hanglog/like/domain/repository/LikeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,14 @@ | ||
package hanglog.like.domain.repository; | ||
|
||
import hanglog.like.domain.Likes; | ||
import hanglog.like.dto.LikeElement; | ||
import hanglog.like.dto.TripLikeCount; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface LikeRepository extends JpaRepository<Likes, Long> { | ||
|
||
@Query(""" | ||
SELECT new hanglog.like.dto.LikeElement | ||
(l.tripId, COUNT(l.memberId), EXISTS(SELECT 1 FROM Likes l_1 WHERE l_1.memberId = :memberId AND l_1.tripId = l.tripId)) | ||
FROM Likes l | ||
WHERE l.tripId in :tripIds | ||
GROUP BY l.tripId | ||
""") | ||
List<LikeElement> findLikeCountAndIsLikeByTripIds(@Param("memberId") final Long memberId, | ||
@Param("tripIds") final List<Long> tripIds); | ||
|
||
@Query(""" | ||
SELECT new hanglog.like.dto.LikeElement | ||
(l.tripId, COUNT(l.memberId), EXISTS(SELECT 1 FROM Likes l_1 WHERE l_1.memberId = :memberId AND l_1.tripId = l.tripId)) | ||
FROM Likes l | ||
WHERE l.tripId = :tripId | ||
GROUP BY l.tripId | ||
""") | ||
Optional<LikeElement> findLikeCountAndIsLikeByTripId(@Param("memberId") final Long memberId, | ||
@Param("tripId") final Long tripId); | ||
|
||
@Query(""" | ||
SELECT new hanglog.like.dto.TripLikeCount(l.tripId, COUNT(l.memberId)) | ||
FROM Likes l | ||
GROUP BY l.tripId | ||
""") | ||
List<TripLikeCount> findCountByAllTrips(); | ||
@Modifying | ||
@Query("DELETE FROM Likes WHERE tripId IN :tripIds") | ||
void deleteByTripIds(final Set<Long> tripIds); | ||
} |
7 changes: 0 additions & 7 deletions
7
backend/src/main/java/hanglog/like/domain/repository/MemberLikeRepository.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.