Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] 족보 상세 조회 API 생성 #38

Merged
merged 10 commits into from
Jul 13, 2024
Merged

[feat] 족보 상세 조회 API 생성 #38

merged 10 commits into from
Jul 13, 2024

Conversation

PicturePark1101
Copy link
Contributor

@PicturePark1101 PicturePark1101 commented Jul 10, 2024

Related Issue 📌

close #27

Description ✔️

  • 족보 상세조회 API
  • Batch 사용 -> 필드에 어노테이션 생성

To Reviewers

Postman test 완료(아래 쿼리 실행 결과)

  • 하이버네이트 6.2부터 in 대신에 array_contains 를 사용한다고 합니다. postgresql 문법에 맞춰서 any로 나가는 것 같습니다.
  • Favorite -> FavoriteStore -> Stroe -> StoreImage 순으로 탐색
Hibernate: 
    select
        f1_0.favorite_id,
        f1_0.created_at,
        f1_0.detail,
        f1_0.name,
        f1_0.updated_at,
        f1_0.user_id 
    from
        favorite f1_0 
    where
        f1_0.favorite_id=?
Hibernate: 
    select
        fs1_0.favorite_id,
        fs1_0.favorite_store_id,
        s1_0.store_id,
        s1_0.category,
        s1_0.created_at,
        s1_0.heart_count,
        s1_0.is_deleted,
        s1_0.lowest_price,
        s1_0.name,
        s1_0.latitude,
        s1_0.longitude,
        s1_0.updated_at 
    from
        favorite_store fs1_0 
    left join
        store s1_0 
            on s1_0.store_id=fs1_0.store_id 
    where
        fs1_0.favorite_id=?
Hibernate: 
    select
        si1_0.store_id,
        si1_0.store_image_id,
        si1_0.created_at,
        si1_0.image_url 
    from
        store_image si1_0 
    where
        si1_0.store_id = any (?)

20240711

  • @manytoone에는 batch 설정 안돼서 (오류남) Store은 엔티티에 @batchsize 설정
  • FavoriteStore FK에 fetchType=Lazy 설정
Hibernate: 
    select
        f1_0.favorite_id,
        f1_0.created_at,
        f1_0.detail,
        f1_0.name,
        f1_0.updated_at,
        f1_0.user_id 
    from
        favorite f1_0 
    where
        f1_0.favorite_id=?
Hibernate: 
    select
        fs1_0.favorite_id,
        fs1_0.favorite_store_id,
        fs1_0.store_id 
    from
        favorite_store fs1_0 
    where
        fs1_0.favorite_id=?
Hibernate: 
    select
        s1_0.store_id,
        s1_0.category,
        s1_0.created_at,
        s1_0.heart_count,
        s1_0.is_deleted,
        s1_0.lowest_price,
        s1_0.name,
        s1_0.latitude,
        s1_0.longitude,
        s1_0.updated_at 
    from
        store s1_0 
    where
        s1_0.store_id = any (?)
Hibernate: 
    select
        si1_0.store_id,
        si1_0.store_image_id,
        si1_0.created_at,
        si1_0.image_url 
    from
        store_image si1_0 
    where
        si1_0.store_id = any (?)


public String getImage() {

if (storeImages.isEmpty()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분 추후 디자인에서 제공하는 default 이미지로 바꿀 예정

@kgy1008 kgy1008 changed the title [feat] Implementing Favorite GET API [feat] 족보 상세 조회 API 생성 Jul 10, 2024
@PicturePark1101
Copy link
Contributor Author

FetctType.LAZY 추가하고 쿼리 테스트 한 번 더 해보기

@PicturePark1101 PicturePark1101 force-pushed the feat/27 branch 2 times, most recently from 3f43407 to 0b5fcb2 Compare July 11, 2024 14:39
Copy link
Contributor

@Parkjyun Parkjyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굿굿입니다

Comment on lines 21 to 24
Favorite favorite = favoriteFinder.findById(id);
List<Store> stores = favorite.getFavoriteStores().stream().map(FavoriteStore::getStore).toList();

return FavoriteFindResponse.of(favorite, stores);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 이런거 favorites랑 stores를 of에 바로 넣는 편이긴 합니다 ㅋ ㅋ

List<FavoriteStoreFindResponse> stores
) {

public static FavoriteFindResponse of(Favorite favorite, List<Store> stores) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사소하지만 여기도 final을 넣어주는 것은 어떨까요

public static FavoriteFindResponse of(Favorite favorite, List<Store> stores) {

List<String> details = new ArrayList<>();
if (favorite.getDetail() != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if 안에 조건문 함수로 빼서 적절한 메서드명을 붙여주세요!

@PicturePark1101 PicturePark1101 force-pushed the feat/27 branch 2 times, most recently from ed68a2d to 0d93eb0 Compare July 12, 2024 18:36
@PicturePark1101 PicturePark1101 merged commit 52d2097 into develop Jul 13, 2024
1 check passed
@kgy1008 kgy1008 deleted the feat/27 branch December 2, 2024 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feat] 족보 상세 조회 API
2 participants