Create Event Design

In this lesson, we'll design the service layer for creating events in our ticket platform.

Domain Objects Design

The first step is creating data transfer objects (DTOs) that will carry the event creation information between layers.

We'll create two DTOs:

@Data @AllArgsConstructor @NoArgsConstructor public class CreateTicketTypeRequest { private String name; private Double price; private String description; private Integer totalAvailable; }
@Data @AllArgsConstructor @NoArgsConstructor public class CreateEventRequest { private String name; private LocalDateTime start; private LocalDateTime end; private String venue; private LocalDateTime salesStart; private LocalDateTime salesEnd; private EventStatusEnum status; private List<CreateTicketTypeRequest> ticketTypes = new ArrayList<>(); }

The CreateTicketTypeRequest contains only the fields needed to create a ticket type, omitting relationships and audit fields. This makes the object focused and easier to validate.

The CreateEventRequest follows the same pattern, including only the data needed to create an event. Notice we're using a list of CreateTicketTypeRequest objects rather than TicketType entities, maintaining the separation between our domain and persistence layers.

Service Interface Design

The service interface defines the contract for creating events:

public interface EventService { Event createEvent(UUID organizerId, CreateEventRequest event); }

The createEvent method takes two parameters:

  • organizerId: The UUID of the user creating the event
  • event: The event creation request containing all event details

This design separates the concerns of user identification from event data, making the code more flexible and easier to test.

Summary

  • Implemented the CreateTicketTypeRequest class
  • Implemented the CreateEventRequest class
  • Created the EventService interface with createEvent method
© 2026 Devtiro Ltd. All rights reserved