-
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.
Merge pull request #674 from woowacourse-teams/develop
Hang-Log Prod 2.0.0 Release
- Loading branch information
Showing
186 changed files
with
5,181 additions
and
604 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 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
14 changes: 14 additions & 0 deletions
14
backend/src/main/java/hanglog/community/domain/BaseTripInfo.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,14 @@ | ||
package hanglog.community.domain; | ||
|
||
public class BaseTripInfo implements TripInfo { | ||
|
||
@Override | ||
public Long getLikeCount() { | ||
return 0L; | ||
} | ||
|
||
@Override | ||
public Boolean getIsLike() { | ||
return false; | ||
} | ||
} |
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 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,8 @@ | ||
package hanglog.community.domain; | ||
|
||
public interface TripInfo { | ||
|
||
Long getLikeCount(); | ||
|
||
Boolean getIsLike(); | ||
} |
34 changes: 34 additions & 0 deletions
34
backend/src/main/java/hanglog/community/domain/recommendstrategy/LikesRecommendStrategy.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,34 @@ | ||
package hanglog.community.domain.recommendstrategy; | ||
|
||
import static hanglog.community.domain.recommendstrategy.RecommendType.LIKE; | ||
|
||
import hanglog.trip.domain.Trip; | ||
import hanglog.trip.domain.repository.TripRepository; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class LikesRecommendStrategy implements RecommendStrategy { | ||
|
||
private static final String TITLE = "지금 인기있는 여행들이에요"; | ||
|
||
private final TripRepository tripRepository; | ||
|
||
@Override | ||
public List<Trip> recommend(final Pageable pageable) { | ||
return tripRepository.findTripsOrderByLikesCount(pageable); | ||
} | ||
|
||
@Override | ||
public boolean isType(final RecommendType recommendType) { | ||
return LIKE.equals(recommendType); | ||
} | ||
|
||
@Override | ||
public String getTitle() { | ||
return TITLE; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
backend/src/main/java/hanglog/community/domain/recommendstrategy/RecommendStrategies.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,21 @@ | ||
package hanglog.community.domain.recommendstrategy; | ||
|
||
import hanglog.global.exception.ExceptionCode; | ||
import hanglog.global.exception.InvalidDomainException; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class RecommendStrategies { | ||
|
||
private final List<RecommendStrategy> recommendStrategies; | ||
|
||
public RecommendStrategy mapByRecommendType(final RecommendType recommendType) { | ||
return recommendStrategies.stream() | ||
.filter(recommendStrategy -> recommendStrategy.isType(recommendType)) | ||
.findFirst() | ||
.orElseThrow(() -> new InvalidDomainException(ExceptionCode.NOT_FOUND_RECOMMEND_TRIP_STRATEGY)); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
backend/src/main/java/hanglog/community/domain/recommendstrategy/RecommendStrategy.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,14 @@ | ||
package hanglog.community.domain.recommendstrategy; | ||
|
||
import hanglog.trip.domain.Trip; | ||
import java.util.List; | ||
import org.springframework.data.domain.Pageable; | ||
|
||
public interface RecommendStrategy { | ||
|
||
List<Trip> recommend(Pageable pageable); | ||
|
||
boolean isType(RecommendType recommendType); | ||
|
||
String getTitle(); | ||
} |
5 changes: 5 additions & 0 deletions
5
backend/src/main/java/hanglog/community/domain/recommendstrategy/RecommendType.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,5 @@ | ||
package hanglog.community.domain.recommendstrategy; | ||
|
||
public enum RecommendType { | ||
LIKE | ||
} |
37 changes: 37 additions & 0 deletions
37
backend/src/main/java/hanglog/community/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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package hanglog.community.domain.repository; | ||
|
||
import hanglog.community.domain.Likes; | ||
import hanglog.community.domain.TripInfo; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface LikeRepository extends JpaRepository<Likes, Long> { | ||
|
||
boolean existsByMemberIdAndTripId(final Long memberId, final Long tripId); | ||
|
||
void deleteByMemberIdAndTripId(final Long memberId, final Long tripId); | ||
|
||
Long countLikesByTripId(final Long tripId); | ||
|
||
@Query(""" | ||
SELECT l.tripId, | ||
COUNT(l.memberId) AS like_count, | ||
EXISTS(SELECT 1 FROM Likes l_1 WHERE l_1.memberId = :memberId AND l_1.tripId = l.tripId) AS is_like | ||
FROM Likes l | ||
WHERE l.tripId in :tripIds | ||
GROUP BY l.tripId | ||
""") | ||
List<Object[]> countByMemberIdAndTripId(@Param("memberId") Long memberId, @Param("tripIds") List<Long> tripIds); | ||
|
||
@Query(""" | ||
SELECT COUNT(l.memberId) AS like_count, | ||
EXISTS(SELECT 1 FROM Likes l_1 WHERE l_1.memberId = :memberId AND l_1.tripId = l.tripId) AS is_like | ||
FROM Likes l | ||
WHERE l.tripId = :tripId | ||
GROUP BY l.tripId | ||
""") | ||
Optional<TripInfo> countByMemberIdAndTripId(@Param("memberId") Long memberId, @Param("tripId") Long tripId); | ||
} |
14 changes: 14 additions & 0 deletions
14
backend/src/main/java/hanglog/community/domain/type/PublishedStatusType.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,14 @@ | ||
package hanglog.community.domain.type; | ||
|
||
public enum PublishedStatusType { | ||
|
||
PUBLISHED, | ||
UNPUBLISHED; | ||
|
||
public static PublishedStatusType mappingType(final boolean isPublished) { | ||
if (isPublished) { | ||
return PUBLISHED; | ||
} | ||
return UNPUBLISHED; | ||
} | ||
} |
Oops, something went wrong.