Using SpringBoot, as REST response, my controller has to return a list of MenuDTO which is a parent class of SimpleMenuDTO and TastingMenuDTO.
I am using ModelMapper to map entity to DTO.
public abstract class MenuEntity {
private String name;
private String description;
private RestaurantEntity restaurant;
}
public class SimpleMenuEntity extends MenuEntity {
private final Set<MenuSectionEntity> sections = new HashSet<>();
}
public class TastingMenuEntity extends MenuEntity {
private BigDecimal price;
private final Set<ProductEntity> products = new HashSet<>();
}
public class MenuDTO {
private String name;
private String description;
private char menuType;
private Long restaurantId;
}
How can I handle this situation?
I am able to change the entities and DTOs.
Aucun commentaire:
Enregistrer un commentaire