47 lines
1.4 KiB
Java
47 lines
1.4 KiB
Java
package app.mealsmadeeasy.api.recipe.view;
|
|
|
|
import app.mealsmadeeasy.api.image.view.ImageView;
|
|
import app.mealsmadeeasy.api.recipe.Recipe;
|
|
import app.mealsmadeeasy.api.user.view.UserInfoView;
|
|
import lombok.Builder;
|
|
import lombok.Value;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
import java.time.OffsetDateTime;
|
|
|
|
@Value
|
|
@Builder
|
|
public class RecipeInfoView {
|
|
|
|
public static RecipeInfoView from(Recipe recipe, int starCount, @Nullable ImageView mainImage) {
|
|
return RecipeInfoView.builder()
|
|
.id(recipe.getId())
|
|
.created(recipe.getCreated())
|
|
.modified(recipe.getModified())
|
|
.slug(recipe.getSlug())
|
|
.title(recipe.getTitle())
|
|
.preparationTime(recipe.getPreparationTime())
|
|
.cookingTime(recipe.getCookingTime())
|
|
.totalTime(recipe.getTotalTime())
|
|
.owner(UserInfoView.from(recipe.getOwner()))
|
|
.isPublic(recipe.getIsPublic())
|
|
.starCount(starCount)
|
|
.mainImage(mainImage)
|
|
.build();
|
|
}
|
|
|
|
Integer id;
|
|
OffsetDateTime created;
|
|
OffsetDateTime modified;
|
|
String slug;
|
|
String title;
|
|
@Nullable Integer preparationTime;
|
|
@Nullable Integer cookingTime;
|
|
@Nullable Integer totalTime;
|
|
UserInfoView owner;
|
|
boolean isPublic;
|
|
int starCount;
|
|
@Nullable ImageView mainImage;
|
|
|
|
}
|