Dtos Mappers

In this lesson, we'll implement the DTOs and mappers needed for the get published event endpoint in the presentation layer.

Implement the DTOs

Let's look at what we need to include in our DTOs:

@Data @AllArgsConstructor @NoArgsConstructor public class GetPublishedEventDetailsResponseDto { private UUID id; private String name; private LocalDateTime start; private LocalDateTime end; private String venue; private List<GetPublishedEventDetailsTicketTypesResponseDto> ticketTypes = new ArrayList<>(); }

For ticket types, we'll create a separate DTO with only the necessary fields:

@Data @AllArgsConstructor @NoArgsConstructor public class GetPublishedEventDetailsTicketTypesResponseDto { private UUID id; private String name; private Double price; private String description; }

Implementing the Mappers

We need to add methods to our EventMapper interface to convert between our domain objects and DTOs:

@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) public interface EventMapper { // ... existing methods ... GetPublishedEventDetailsTicketTypesResponseDto toGetPublishedEventDetailsTicketTypesResponseDto(TicketType ticketType); GetPublishedEventDetailsResponseDto toGetPublishedEventDetailsResponseDto(Event event); }

The @Mapper annotation tells MapStruct to generate the implementation of these methods.

Summary

  • Added the GetPublishedEventDetailsResponseDto and GetPublishedEventDetailsTicketTypesResponseDto DTO classes
  • Added the toGetPublishedEventDetailsResponseDto and toGetPublishedEventDetailsTicketTypesResponseDto mapper methods
© 2026 Devtiro Ltd. All rights reserved