Skip to content
New issue

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

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

Already on GitHub? # to your account

[#116] 전체 유저의 행복 지도 API 구축 #117

Merged
merged 2 commits into from
Jun 1, 2024
Merged

Conversation

yel-m
Copy link
Member

@yel-m yel-m commented Jun 1, 2024

#️⃣ 연관된 이슈

Resolves #116

📝 작업 내용

이번 PR에서 작업한 내용을 간략히 설명해주세요 (이미지 첨부 가능)

  • 전체 유저의 행복 지도 API를 구축했습니다.

  • 행복 장소와 행복 활동을 모두 조회하므로 서비스와 DTO 이름을 각각 LocationActivityService와 LocationActivityResponseDto로 지었는데, 혹시 더 좋은 이름이 있다면 언제든지 추천해주세용!

  • LocationHappinessAnalyzer의 getLocationActivityRankings 메서드에서 Null인 객체에 대하여 getter 메서드를 사용할 경우 NullPointerException이 발생하기 때문에 다음과 같이 예외 처리를 해주었습니다.

    Location location = happiestRecord != null ? happiestRecord.getLocation() : null;
    String happiesActivity = happiestRecord != null ? happiestRecord.getActivity().getName() : null;
  • 마찬가지의 이유로 toLocationActivityResponseDto 컨버터에도 다음과 같이 예외 처리를 해주었습니다.

    public static LocationActivityRankingResponseDto toLocationActivityRankingResponseDto(int ranking, Location location, String happinesActivity) {
            return LocationActivityRankingResponseDto.builder()
                    .ranking(ranking)
                    .location(location != null ? location.getCity() + " " + location.getDistrict() : null)
                    .latitude(location != null ? location.getLatitude() : null)
                    .longitude(location != null ? location.getLongitude() : null)
                    .happiestActivity(happinesActivity)
                    .build();
    
        }

예시

api/trend/top-locations로 요청 시, 다음과 같은 응답을 받을 수 있습니다.

  • 데이터가 없을 경우
    {
      "success": true,
      "code": 0,
      "message": "행복도가 높은 장소와 활동 Top3를 성공적으로 조회했습니다.",
      "data": [
        {
          "ranking": 1,
          "location": null,
          "latitude": null,
          "longitude": null,
          "happiestActivity": null
        },
        {
          "ranking": 2,
          "location": null,
          "latitude": null,
          "longitude": null,
          "happiestActivity": null
        },
        {
          "ranking": 3,
          "location": null,
          "latitude": null,
          "longitude": null,
          "happiestActivity": null
        }
      ]
    }
  • 데이터가 두 개인 경우
    {
      "success": true,
      "code": 0,
      "message": "행복도가 높은 장소와 활동 Top3를 성공적으로 조회했습니다.",
      "data": [
        {
          "ranking": 1,
          "location": "서울특별시 동작구",
          "latitude": 0,
          "longitude": 0,
          "happiestActivity": "계획 세우기"
        },
        {
          "ranking": 2,
          "location": "서울특별시 마포동",
          "latitude": 0,
          "longitude": 0,
          "happiestActivity": "카페 가기"
        },
        {
          "ranking": 3,
          "location": null,
          "latitude": null,
          "longitude": null,
          "happiestActivity": null
        }
      ]
    }
  • 데이터가 3개 이상인 경우
    {
      "success": true,
      "code": 0,
      "message": "행복도가 높은 장소와 활동 Top3를 성공적으로 조회했습니다.",
      "data": [
        {
          "ranking": 1,
          "location": "서울특별시 연신내",
          "latitude": 0,
          "longitude": 0,
          "happiestActivity": "쇼핑하기"
        },
        {
          "ranking": 2,
          "location": "인천광역시 청라동",
          "latitude": 0,
          "longitude": 0,
          "happiestActivity": "카페 가기"
        },
        {
          "ranking": 3,
          "location": "서울특별시 마포동",
          "latitude": 0,
          "longitude": 0,
          "happiestActivity": "카페 가기"
        }
      ]
    }

스크린샷 (선택)

💬 리뷰 요구사항(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

✅ Check List

  • PR 제목을 커밋 규칙에 맞게 작성했는가?
  • PR에 해당되는 Issue를 연결했는가?
  • 적절한 라벨을 설정했는가?
  • 작업한 사람을 모두 Assign했는가?

@yel-m yel-m requested a review from KkomSang June 1, 2024 07:46
@yel-m yel-m self-assigned this Jun 1, 2024
@yel-m yel-m added the feat 새로운 기능을 추가합니다 label Jun 1, 2024
@KkomSang
Copy link
Collaborator

KkomSang commented Jun 1, 2024

예외처리까지..!!! 너무나도 꼼꼼하고 좋은 코드네용 수고하셨습니당😍
트렌드 개발이 생각보다 빠르게 진행되어서 좋으네용!! >_<

@KkomSang KkomSang merged commit 7f2ec1b into develop Jun 1, 2024
1 check passed
@KkomSang KkomSang deleted the feat/#116 branch June 1, 2024 14:55
@yel-m
Copy link
Member Author

yel-m commented Jun 2, 2024

@KkomSang
그르니까용!!
사금양 같이 넘 수고 많았다요🍀💛💛 뿅뿅

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feat 새로운 기능을 추가합니다
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants