@Override
public ArrayList<RoomResponseDTO> toDTOsFromMenti(List<Room> room, Menti receiver) {
if ( room == null && receiver == null ) {
return null;
}
ArrayList<RoomResponseDTO> arrayList = new ArrayList<RoomResponseDTO>();
return arrayList;
}
@Override
public RoomResponseDTO toDTOFromMenti(Room room, Menti receiver) {
if ( room == null && receiver == null ) {
return null;
}
RoomResponseDTO.RoomResponseDTOBuilder roomResponseDTO = RoomResponseDTO.builder();
if ( room != null ) {
roomResponseDTO.roomPK( room.getId() );
roomResponseDTO.lastLetter( RoomMapper.letterListToStr( room.getLetterList() ) );
roomResponseDTO.updateAt( room.getLastSendTime() );
}
if ( receiver != null ) {
roomResponseDTO.nickname( receiver.getNickname() );
roomResponseDTO.memberPK( receiver.getMentiId() );
roomResponseDTO.major( RoomMapper.initMentiMajor( receiver.getMemberMajors() ) );
}
return roomResponseDTO.build();
}
}
toDTOsFromMenti가 → toDTOFromMenti로 자연스럽게 매핑이 되지 않는 문제
default ArrayList<RoomResponseDTO> toDTOsFromMento(List<Room> room, Mento receiver) {
ArrayList<RoomResponseDTO> roomResponseDTOList = new ArrayList<>();
for (Room roomEntity : room) {
RoomResponseDTO roomResponseDTO = toDTOFromMento(roomEntity, receiver);
roomResponseDTOList.add(roomResponseDTO);
}
return roomResponseDTOList;
}
@Mapping(source = "room.id", target = "roomPK")
@Mapping(source = "receiver.nickname", target = "nickname")
@Mapping(source = "receiver.mentoId", target = "memberPK")
@Mapping(source = "room.letterList", target = "lastLetter", qualifiedByName = "letterListToStr")
@Mapping(source = "receiver.memberMajors", target = "major", qualifiedByName = "initMentoMajor")
@Mapping(source = "room.lastSendTime", target = "updateAt")
RoomResponseDTO toDTOFromMento(Room room, Mento receiver);
인터페이스 default 메서드를 통해서 인터페이스 내에서 직접 for문을 통해 일일이 toDTOFromMento 메서드를 통해 엔티티 인자를 컬렉션 인자로 변환시킴.