Files
mtusi2026lab6/src/main/java/ru/mtusi/messenger/mapper/MessageMapper.java
T

32 lines
1.1 KiB
Java

package ru.mtusi.messenger.mapper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import ru.mtusi.messenger.dto.CreateMessageDTO;
import ru.mtusi.messenger.dto.MessageDTO;
import ru.mtusi.messenger.model.Message;
@Mapper(componentModel = "spring")
public interface MessageMapper {
@Mapping(target = "id", ignore = true)
@Mapping(target = "chat", ignore = true)
@Mapping(target = "sender", ignore = true)
@Mapping(target = "createdAt", ignore = true)
@Mapping(target = "attachmentIds", ignore = true)
Message toMessage(MessageDTO dto);
@Mapping(target = "chatId", source = "chat.id")
@Mapping(target = "senderId", source = "sender.id")
@Mapping(target = "attachmentIds", source = "attachmentIds")
MessageDTO toMessageDTO(Message entity);
@Mapping(target = "id", ignore = true)
@Mapping(target = "chat", ignore = true)
@Mapping(target = "sender", ignore = true)
@Mapping(target = "createdAt", ignore = true)
@Mapping(target = "attachmentIds", source = "attachmentIds")
Message toMessage(CreateMessageDTO dto);
}