package com.gnx.telemedicine.mappers;

import com.gnx.telemedicine.dto.message.MessageResponseDto;
import com.gnx.telemedicine.model.Message;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper(componentModel = "spring")
public interface MessageMapper {
    MessageMapper INSTANCE = Mappers.getMapper(MessageMapper.class);

    @Mapping(source = "sender.id", target = "senderId")
    @Mapping(expression = "java(message.getSender().getFirstName() + \" \" + message.getSender().getLastName())", target = "senderName")
    @Mapping(source = "receiver.id", target = "receiverId")
    @Mapping(expression = "java(message.getReceiver().getFirstName() + \" \" + message.getReceiver().getLastName())", target = "receiverName")
    MessageResponseDto toDto(Message message);

    List<MessageResponseDto> toDtoList(List<Message> messages);
}

