From 23434165a41a03cfaab1a0037a7aa0fe9081b750 Mon Sep 17 00:00:00 2001 From: mmihye Date: Fri, 7 Jun 2024 18:30:43 +0900 Subject: [PATCH] =?UTF-8?q?[#50]=20feat:=20=EB=B6=81=EB=A7=88=ED=81=AC?= =?UTF-8?q?=ED=95=9C=20=EC=97=AC=ED=96=89=EC=A7=80=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/place/controller/PlaceController.java | 7 +++++++ .../place/dto/response/PlaceBookmarkDto.java | 14 ++++++++++++++ .../domain/place/service/PlaceService.java | 9 +++++++++ .../domain/placeBookbark/entity/PlaceBookmark.java | 3 ++- .../repository/PlaceBookmarkRepository.java | 4 ++++ .../Journey/Together/global/exception/Success.java | 7 +++---- 6 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 src/main/java/Journey/Together/domain/place/dto/response/PlaceBookmarkDto.java diff --git a/src/main/java/Journey/Together/domain/place/controller/PlaceController.java b/src/main/java/Journey/Together/domain/place/controller/PlaceController.java index aea9492..ae83914 100644 --- a/src/main/java/Journey/Together/domain/place/controller/PlaceController.java +++ b/src/main/java/Journey/Together/domain/place/controller/PlaceController.java @@ -3,6 +3,7 @@ import Journey.Together.domain.place.dto.request.PlaceReviewReq; import Journey.Together.domain.place.dto.response.*; import Journey.Together.domain.place.service.PlaceService; +import Journey.Together.domain.placeBookbark.entity.PlaceBookmark; import Journey.Together.global.common.ApiResponse; import Journey.Together.global.exception.Success; import Journey.Together.global.security.PrincipalDetails; @@ -74,4 +75,10 @@ public ApiResponse getPlaceMyReview( return ApiResponse.success(Success.GET_MY_PLACE_REVIEW_SUCCESS,placeService.getReview(principalDetails.getMember(),reviewId)); } + @GetMapping("/bookmark") + public ApiResponse> getBookmarkPlaceNames( + @AuthenticationPrincipal PrincipalDetails principalDetails){ + return ApiResponse.success(Success.GET_BOOKMARK_PLACE_NAMES_SUCCESS, placeService.getBookmarkPlaceNames(principalDetails.getMember())); + } + } diff --git a/src/main/java/Journey/Together/domain/place/dto/response/PlaceBookmarkDto.java b/src/main/java/Journey/Together/domain/place/dto/response/PlaceBookmarkDto.java new file mode 100644 index 0000000..8a36940 --- /dev/null +++ b/src/main/java/Journey/Together/domain/place/dto/response/PlaceBookmarkDto.java @@ -0,0 +1,14 @@ +package Journey.Together.domain.place.dto.response; + +import Journey.Together.domain.place.entity.Place; +import Journey.Together.domain.placeBookbark.entity.PlaceBookmark; + +public record PlaceBookmarkDto( + Long placeId, + String placeName +) { + + public static PlaceBookmarkDto of(PlaceBookmark placeBookmark){ + return new PlaceBookmarkDto(placeBookmark.getPlace().getId(), placeBookmark.getPlace().getName()); + } +} diff --git a/src/main/java/Journey/Together/domain/place/service/PlaceService.java b/src/main/java/Journey/Together/domain/place/service/PlaceService.java index 1b63e93..14c44e1 100644 --- a/src/main/java/Journey/Together/domain/place/service/PlaceService.java +++ b/src/main/java/Journey/Together/domain/place/service/PlaceService.java @@ -169,6 +169,15 @@ public MyReview getReview(Member member, Long reviewId){ return MyReview.of(placeReview, list); } + //북마크한 여행지 이름만 가져오기 + public List getBookmarkPlaceNames(Member member){ + List placeBookmarkList = placeBookmarkRepository.findAllByMemberOrderByPlaceNameAsc(member); + if(placeBookmarkList.isEmpty() || placeBookmarkList==null) + return new ArrayList<>(); + + return placeBookmarkList.stream().map(PlaceBookmarkDto::of).toList(); + } + private List getPlaceRes(List list){ List placeList = new ArrayList<>(); diff --git a/src/main/java/Journey/Together/domain/placeBookbark/entity/PlaceBookmark.java b/src/main/java/Journey/Together/domain/placeBookbark/entity/PlaceBookmark.java index 5fb7660..b9ef303 100644 --- a/src/main/java/Journey/Together/domain/placeBookbark/entity/PlaceBookmark.java +++ b/src/main/java/Journey/Together/domain/placeBookbark/entity/PlaceBookmark.java @@ -2,6 +2,7 @@ import Journey.Together.domain.member.entity.Member; import Journey.Together.domain.place.entity.Place; +import Journey.Together.global.common.BaseTimeEntity; import jakarta.persistence.*; import lombok.*; @@ -10,7 +11,7 @@ @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor -public class PlaceBookmark { +public class PlaceBookmark extends BaseTimeEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/Journey/Together/domain/placeBookbark/repository/PlaceBookmarkRepository.java b/src/main/java/Journey/Together/domain/placeBookbark/repository/PlaceBookmarkRepository.java index 5d82f64..5813839 100644 --- a/src/main/java/Journey/Together/domain/placeBookbark/repository/PlaceBookmarkRepository.java +++ b/src/main/java/Journey/Together/domain/placeBookbark/repository/PlaceBookmarkRepository.java @@ -1,6 +1,7 @@ package Journey.Together.domain.placeBookbark.repository; +import Journey.Together.domain.member.entity.Member; import Journey.Together.domain.place.entity.Place; import Journey.Together.domain.placeBookbark.entity.PlaceBookmark; import org.springframework.data.jpa.repository.JpaRepository; @@ -8,10 +9,13 @@ import org.springframework.data.repository.query.Param; import java.util.List; +import java.util.Map; public interface PlaceBookmarkRepository extends JpaRepository { List findAllByPlace(Place place); + List findAllByMemberOrderByPlaceNameAsc(Member member); + } diff --git a/src/main/java/Journey/Together/global/exception/Success.java b/src/main/java/Journey/Together/global/exception/Success.java index 3e92260..46b461d 100644 --- a/src/main/java/Journey/Together/global/exception/Success.java +++ b/src/main/java/Journey/Together/global/exception/Success.java @@ -23,6 +23,7 @@ public enum Success { GET_PLACE_REVIEW_LIST_SUCCESS(HttpStatus.OK, "관광정보 후기 목록 조회 성공"), GET_MY_PLACE_REVIEW_LIST_SUCCESS(HttpStatus.OK, "나의 여행지 후기 목록 조회 성공"), GET_MY_PLACE_REVIEW_SUCCESS(HttpStatus.OK, "나의 여행지 후기 조회 성공"), + GET_BOOKMARK_PLACE_NAMES_SUCCESS(HttpStatus.OK, "북마크한 여행지 조회 성공"), GET_USER_INTEREST_SUCCESS(HttpStatus.OK, "사용자 관심 유형 정보 조회 성공"), GET_MAIN_SUCCESS(HttpStatus.OK, "메인 페이지 정보 조회 성공"), GET_PLACE_DETAIL_SUCCESS(HttpStatus.OK, "여행지 상세정보 조회 성공"), @@ -38,7 +39,7 @@ public enum Success { GET_TIMER_PAGE_SUCCESS(HttpStatus.OK, "타이머 페이지 조회 성공"), GET_DUPLICATED_SUCCESS(HttpStatus.OK, "중복 여부 체크 성공"), - LOGIN_SUCCESS(HttpStatus.OK, "로그인 성공"), + LOGIN_SUCCESS(HttpStatus.OK, "로그인 성공"), RE_ISSUE_TOKEN_SUCCESS(HttpStatus.OK, "토큰 재발급 성공"), SIGNOUT_SUCCESS(HttpStatus.OK, "로그아웃 성공"), DELETE_USER_SUCCESS(HttpStatus.OK, "회원 탈퇴가 정상적으로 이루어졌습니다."), @@ -65,9 +66,7 @@ public enum Success { /** * 204 NO_CONTENT */ - SEARCH_SUCCESS_BUT_IS_EMPTY(HttpStatus.NO_CONTENT, "검색에 성공했지만 조회된 내용이 없습니다.") - - ; + SEARCH_SUCCESS_BUT_IS_EMPTY(HttpStatus.NO_CONTENT, "검색에 성공했지만 조회된 내용이 없습니다."); private final HttpStatus httpStatus; private final String message;