-
Notifications
You must be signed in to change notification settings - Fork 2
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
…page [Feat] #142 마이페이지에 필요한 정보를 반환해요
- Loading branch information
Showing
21 changed files
with
414 additions
and
39 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
4 changes: 4 additions & 0 deletions
4
src/main/java/team7/inplace/likedPlace/persistence/LikedPlaceRepository.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,10 +1,14 @@ | ||
package team7.inplace.likedPlace.persistence; | ||
|
||
import java.util.Optional; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import team7.inplace.likedPlace.domain.LikedPlace; | ||
|
||
public interface LikedPlaceRepository extends JpaRepository<LikedPlace, Long> { | ||
|
||
Optional<LikedPlace> findByUserIdAndPlaceId(Long userId, Long placeId); | ||
|
||
Page<LikedPlace> findByUserIdAndIsLikedTrue(Long userId, Pageable pageable); | ||
} |
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
23 changes: 23 additions & 0 deletions
23
src/main/java/team7/inplace/place/application/dto/LikedPlaceInfo.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,23 @@ | ||
package team7.inplace.place.application.dto; | ||
|
||
|
||
import team7.inplace.likedPlace.domain.LikedPlace; | ||
|
||
public record LikedPlaceInfo( | ||
Long placeId, | ||
String placeName, | ||
String imageUrl, | ||
String influencerName, | ||
boolean likes | ||
) { | ||
|
||
public static LikedPlaceInfo of(LikedPlace likedPlace, String influencerName) { | ||
return new LikedPlaceInfo( | ||
likedPlace.getPlace().getId(), | ||
likedPlace.getPlace().getName(), | ||
likedPlace.getPlace().getMenuImgUrl(), | ||
influencerName, | ||
likedPlace.isLiked() | ||
); | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
src/main/java/team7/inplace/review/application/dto/MyReviewInfo.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,41 @@ | ||
package team7.inplace.review.application.dto; | ||
|
||
import java.util.Date; | ||
import team7.inplace.place.application.dto.PlaceInfo.AddressInfo; | ||
import team7.inplace.place.domain.Place; | ||
import team7.inplace.review.domain.Review; | ||
|
||
|
||
public record MyReviewInfo( | ||
Long reviewId, | ||
boolean likes, | ||
String comment, | ||
Date createdDate, | ||
ReviewPlaceInfo placeInfo | ||
) { | ||
|
||
public record ReviewPlaceInfo( | ||
Long placeId, | ||
String imgUrl, | ||
AddressInfo address | ||
) { | ||
|
||
public static ReviewPlaceInfo from(Place place) { | ||
return new ReviewPlaceInfo( | ||
place.getId(), | ||
place.getMenuImgUrl(), | ||
AddressInfo.of(place.getAddress()) | ||
); | ||
} | ||
} | ||
|
||
public static MyReviewInfo from(Review review) { | ||
return new MyReviewInfo( | ||
review.getId(), | ||
review.isLiked(), | ||
review.getComment(), | ||
review.getCreatedDate(), | ||
ReviewPlaceInfo.from(review.getPlace()) | ||
); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
src/main/java/team7/inplace/review/presentation/ReviewControllerApiSpec.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,11 @@ | ||
package team7.inplace.review.presentation; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
|
||
public interface ReviewControllerApiSpec { | ||
|
||
@Operation(summary = "리뷰 삭제", description = "본인이 작성한 리뷰를 삭제합니다.") | ||
ResponseEntity<Void> deleteReview(@PathVariable Long id); | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/team7/inplace/security/application/CurrentUserProvider.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,26 @@ | ||
package team7.inplace.security.application; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import team7.inplace.global.exception.InplaceException; | ||
import team7.inplace.global.exception.code.AuthorizationErrorCode; | ||
import team7.inplace.global.exception.code.UserErrorCode; | ||
import team7.inplace.security.util.AuthorizationUtil; | ||
import team7.inplace.user.domain.User; | ||
import team7.inplace.user.persistence.UserRepository; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class CurrentUserProvider { | ||
|
||
private final UserRepository userRepository; | ||
|
||
public User getCurrentUser() { | ||
Long userId = AuthorizationUtil.getUserId(); | ||
if (userId == null) { | ||
throw InplaceException.of(AuthorizationErrorCode.TOKEN_IS_EMPTY); | ||
} | ||
return userRepository.findById(userId) | ||
.orElseThrow(() -> InplaceException.of(UserErrorCode.NOT_FOUND)); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/team7/inplace/user/application/UserFacade.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,48 @@ | ||
package team7.inplace.user.application; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import team7.inplace.favoriteInfluencer.application.FavoriteInfluencerService; | ||
import team7.inplace.global.annotation.Facade; | ||
import team7.inplace.global.exception.InplaceException; | ||
import team7.inplace.global.exception.code.AuthorizationErrorCode; | ||
import team7.inplace.influencer.application.dto.InfluencerInfo; | ||
import team7.inplace.place.application.PlaceService; | ||
import team7.inplace.place.application.dto.LikedPlaceInfo; | ||
import team7.inplace.review.application.ReviewService; | ||
import team7.inplace.review.application.dto.MyReviewInfo; | ||
import team7.inplace.security.util.AuthorizationUtil; | ||
|
||
@Facade | ||
@RequiredArgsConstructor | ||
public class UserFacade { | ||
|
||
private final FavoriteInfluencerService favoriteInfluencerService; | ||
private final PlaceService placeService; | ||
private final ReviewService reviewService; | ||
|
||
public Page<InfluencerInfo> getMyFavoriteInfluencers(Pageable pageable) { | ||
if (AuthorizationUtil.isNotLoginUser()) { | ||
throw InplaceException.of(AuthorizationErrorCode.TOKEN_IS_EMPTY); | ||
} | ||
Long userId = AuthorizationUtil.getUserId(); | ||
return favoriteInfluencerService.getFavoriteInfluencers(userId, pageable); | ||
} | ||
|
||
public Page<LikedPlaceInfo> getMyFavoritePlaces(Pageable pageable) { | ||
if (AuthorizationUtil.isNotLoginUser()) { | ||
throw InplaceException.of(AuthorizationErrorCode.TOKEN_IS_EMPTY); | ||
} | ||
Long userId = AuthorizationUtil.getUserId(); | ||
return placeService.getLikedPlaceInfo(userId, pageable); | ||
} | ||
|
||
public Page<MyReviewInfo> getMyReviews(Pageable pageable) { | ||
if (AuthorizationUtil.isNotLoginUser()) { | ||
throw InplaceException.of(AuthorizationErrorCode.TOKEN_IS_EMPTY); | ||
} | ||
Long userId = AuthorizationUtil.getUserId(); | ||
return reviewService.getMyReviews(userId, pageable); | ||
} | ||
} |
Oops, something went wrong.