Create Restaurant Design
In this lesson, we'll build the foundation for creating restaurants in our review platform by designing the service layer components.
This builds upon our previous work with the GeoLocation service, adding the necessary structures to handle restaurant creation requests.
Domain Objects
Let's create the RestaurantCreateUpdateRequest class which will serve as our data transfer object for both creating and updating restaurants:
package com.devtiro.restaurant.domain;
import com.devtiro.restaurant.domain.entities.Address;
import com.devtiro.restaurant.domain.entities.OperatingHours;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class RestaurantCreateUpdateRequest {
private String name; // Restaurant's name
private String cuisineType; // Type of cuisine served
private String contactInformation; // Contact details
private Address address; // Physical location
private OperatingHours operatingHours; // Opening hours
private List<String> photoIds; // References to uploaded photos
}Service Interface
The service layer requires a clear interface to define the operations available for restaurant management:
package com.devtiro.restaurant.services;
import com.devtiro.restaurant.domain.RestaurantCreateRequest;
import com.devtiro.restaurant.domain.entities.Restaurant;
public interface RestaurantService {
// Creates a new restaurant and returns the created entity
Restaurant createRestaurant(RestaurantCreateRequest restaurant);
}Summary
- Created
RestaurantCreateUpdateRequestclass to capture restaurant details - Defined
RestaurantServiceinterface withcreateRestaurantmethod