Igloo-Club / Igloo-Club-BE

1 stars 1 forks source link

[fix] 매칭된 눈길 상세 조회 기능 전반적으로 수정 #57

Closed clap-0 closed 7 months ago

clap-0 commented 7 months ago

🔥 Related Issues

💜 작업 내용

✅ PR Point

1️⃣Nungil 엔티티의 서로 겹치는 요일, 시간, 마커 리스트를 Enum 변경

    @Nullable
    private Yoil matchedYoil;

    // 리스트를 쉼표로 구분된 문자열로 DB에 저장
    @Convert(converter = MarkerListConverter.class)
    @Builder.Default
    private List<Marker> matchedMarkers = new ArrayList<>();

    @Nullable
    private AvailableTime matchedAvailableTime;

2️⃣매칭된 눈길 상세 조회 응답 데이터 수정

public class NungilMatchResponse {

    @Nullable
    private String yoil;

    @Nullable
    private String time;

    private List<AvailableMarker> marker;

    private String location;

    @Nullable
    private Long chatRoomId;

    ...
}

3️⃣ API 요청을 보낸 사용자 권한 확인 로직 추가

public NungilMatchResponse getMatchedNungil(Long nungilId, Member member){

    Nungil nungil = nungilRepository.findById(nungilId)
            .orElseThrow(() -> new GeneralException(NungilErrorResult.NUNGIL_NOT_FOUND));

    // 요청을 보낸 사용자가 주어진 눈길의 소유자인지 확인한다.
    if (!nungil.getMember().equals(member)) {
        throw new GeneralException(MemberErrorResult.NOT_OWNER);
    }
    ...
}

4️⃣ 판교 마커 데이터

PANGYO_STATION_SQUARE("판교역 광장", 37.39525750009229, 127.11148651523494, Location.PANGYO),
EOUL_PARK("어울공원 광장", 37.4016955, 127.1113852, Location.PANGYO),
USPACE_SQUARE("유스페이스 야외광장 말 조형물", 37.4015951616412, 127.107432606539, Location.PANGYO),
FANTASY_CHILDREN_PARK("환상어린이공원 지구본 조형물", 37.4016223752017, 127.102142688358, Location.PANGYO),
SPACE_PARK("우주공원", 37.4040322946287, 127.1013519549, Location.PANGYO),

😡 Trouble Shooting

public static NungilMatchResponse create(Nungil nungil, Long chatRoomId) {
    NungilMatchResponse response = new NungilMatchResponse();
    ...
    Location location = nungil.getReceiver().getLocation();
      response.location = (location != null) ? location.getTitle() : null;
}