Update Design
In this lesson, we'll create the objects and interface declaration needed for implementing the update event endpoint, building on our existing event management functionality.
Design Overview
Let's start by examining what we need for our update functionality.
When updating an event, we want to replace all the event data with new data, except for system-managed fields like id, createdAt, and updatedAt.
Here's how we'll structure our update objects:
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UpdateEventRequest {
private UUID id;
private String name;
private LocalDateTime start;
private LocalDateTime end;
private String venue;
private LocalDateTime salesStart;
private LocalDateTime salesEnd;
private EventStatusEnum status;
private List<UpdateTicketTypeRequest> ticketTypes = new ArrayList<>();
}@Data
@AllArgsConstructor
@NoArgsConstructor
public class UpdateTicketTypeRequest {
private UUID id;
private String name;
private Double price;
private String description;
private Integer totalAvailable;
}Service Interface Declaration
We need to declare our update method in the EventService interface.
The method needs to:
- Take the organizer's ID to verify ownership
- Take the event ID to identify which event to update
- Accept the update request containing the new data
- Return the updated event
Here's the interface declaration:
public interface EventService {
// ... existing methods ...
Event updateEventForOrganizer(UUID organizerId, UUID id, UpdateEventRequest event);
}Summary
- Added the
UpdateTicketTypeRequestclass - Added the
updateEventForOrganizermethod to theEventServiceinterface