Skip to content

Commit

Permalink
[COZY-198] feat: 방 정보 조회 시 mateId 포함 (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpark0506 authored Aug 20, 2024
1 parent 69e0a13 commit 41e0450
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.cozymate.cozymate_server.domain.mate.Mate;
import com.cozymate.cozymate_server.domain.member.Member;
import com.cozymate.cozymate_server.domain.room.Room;
import com.cozymate.cozymate_server.domain.room.dto.CozymateInfoResponse;
import com.cozymate.cozymate_server.domain.room.dto.CozymateResponse;
import com.cozymate.cozymate_server.domain.room.dto.InviteRequest;
import com.cozymate.cozymate_server.domain.room.dto.RoomCreateRequest;
Expand Down Expand Up @@ -38,6 +39,14 @@ public static CozymateResponse toCozymateResponse(Member member) {
.build();
}

public static CozymateInfoResponse toCozyMateInfoResponse(Mate mate) {
return CozymateInfoResponse.builder()
.memberId(mate.getMember().getId())
.mateId(mate.getId())
.nickname(mate.getMember().getNickname())
.build();
}

public static InviteRequest toInviteRequest(Room room, Mate mate){
return InviteRequest.builder()
.roomId(room.getId())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.cozymate.cozymate_server.domain.room.dto;

import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class CozymateInfoResponse {

private Long memberId;
private Long mateId;
private String nickname;


}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ public class RoomCreateResponse {
private String name;
private String inviteCode;
private Integer profileImage;
List<CozymateResponse> mateList;
List<CozymateInfoResponse> mateList;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.cozymate.cozymate_server.domain.member.repository.MemberRepository;
import com.cozymate.cozymate_server.domain.room.Room;
import com.cozymate.cozymate_server.domain.room.converter.RoomConverter;
import com.cozymate.cozymate_server.domain.room.dto.CozymateInfoResponse;
import com.cozymate.cozymate_server.domain.room.dto.CozymateResponse;
import com.cozymate.cozymate_server.domain.room.dto.InviteRequest;
import com.cozymate.cozymate_server.domain.room.dto.RoomCreateResponse;
Expand Down Expand Up @@ -47,9 +48,9 @@ public RoomCreateResponse getRoomById(Long roomId, Long memberId) {
mateRepository.findByRoomIdAndMemberId(roomId, memberId)
.orElseThrow(() -> new GeneralException(ErrorStatus._NOT_ROOM_MATE));

List<CozymateResponse> mates = mateRepository.findByRoomId(roomId).stream()
List<CozymateInfoResponse> mates = mateRepository.findByRoomId(roomId).stream()
.filter(mate->mate.getEntryStatus().equals(EntryStatus.JOINED))
.map(mate->RoomConverter.toCozymateResponse(mate.getMember()))
.map(RoomConverter::toCozyMateInfoResponse)
.toList();

return new RoomCreateResponse(room.getId(), room.getName(), room.getInviteCode(), room.getProfileImage(),
Expand Down

0 comments on commit 41e0450

Please sign in to comment.