Skip to content

Commit

Permalink
[#50] feat: 북마크한 여행지 이름가져오기
Browse files Browse the repository at this point in the history
  • Loading branch information
mmihye committed Jun 7, 2024
1 parent 75bcf88 commit 2343416
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,4 +75,10 @@ public ApiResponse<MyReview> getPlaceMyReview(
return ApiResponse.success(Success.GET_MY_PLACE_REVIEW_SUCCESS,placeService.getReview(principalDetails.getMember(),reviewId));
}

@GetMapping("/bookmark")
public ApiResponse<List<PlaceBookmarkDto>> getBookmarkPlaceNames(
@AuthenticationPrincipal PrincipalDetails principalDetails){
return ApiResponse.success(Success.GET_BOOKMARK_PLACE_NAMES_SUCCESS, placeService.getBookmarkPlaceNames(principalDetails.getMember()));
}

}
Original file line number Diff line number Diff line change
@@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ public MyReview getReview(Member member, Long reviewId){
return MyReview.of(placeReview, list);
}

//북마크한 여행지 이름만 가져오기
public List<PlaceBookmarkDto> getBookmarkPlaceNames(Member member){
List<PlaceBookmark> placeBookmarkList = placeBookmarkRepository.findAllByMemberOrderByPlaceNameAsc(member);
if(placeBookmarkList.isEmpty() || placeBookmarkList==null)
return new ArrayList<>();

return placeBookmarkList.stream().map(PlaceBookmarkDto::of).toList();
}

private List<PlaceRes> getPlaceRes(List<Place> list){
List<PlaceRes> placeList = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand All @@ -10,7 +11,7 @@
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class PlaceBookmark {
public class PlaceBookmark extends BaseTimeEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
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;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Map;

public interface PlaceBookmarkRepository extends JpaRepository<PlaceBookmark, Long> {

List<PlaceBookmark> findAllByPlace(Place place);

List<PlaceBookmark> findAllByMemberOrderByPlaceNameAsc(Member member);


}
7 changes: 3 additions & 4 deletions src/main/java/Journey/Together/global/exception/Success.java
Original file line number Diff line number Diff line change
Expand Up @@ -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, "여행지 상세정보 조회 성공"),
Expand All @@ -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, "회원 탈퇴가 정상적으로 이루어졌습니다."),
Expand All @@ -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;
Expand Down

0 comments on commit 2343416

Please sign in to comment.