Maper
@Mapper(componentModel = "spring")
public interface MealMapper {
@Named("createMealToEntity")
@Mapping(source = "restaurantId", target = "restaurantId")
@Mapping(ignore = true, target = "mealId")
Meal createMealToEntity(CreateMealDto createMealDto,String restaurantId);
@IterableMapping(qualifiedByName = "createMealToEntity")
List<Meal> createListMealToEntity(List<CreateMealDto> createMealDtoList, String restaurantId);
List<MealDto> entityToDto(List<Meal> mealList);
}
CreateMealDto
@Getter
@Setter
@NoArgsConstructor
public class CreateMealDto {
private String name;
private Double price;
private String imageUrl;
private String ingredients;
private Double timeToDo;
}
Meal
public class Meal {
@Id
@GeneratedValue(generator = "UUID")
@GenericGenerator(
name = "UUID",
strategy = "org.hibernate.id.UUIDGenerator"
)
@Column(name = "meal_id")
private String mealId;
@Column(name = "name")
private String name;
@Column(name = "price")
private Double price;
@Column(name = "image_url")
private String imageUrl;
@Column(name = "ingredients")
private String ingredients;
@Column(name = "time_to_do")
private Double timeToDo;
@Column(name = "restaurant_id")
private String restaurantId;
}