Generate random ids for instructions and ingredients

This commit is contained in:
Kirill Kamakin
2022-10-30 13:21:27 +01:00
parent 64d4d47be2
commit 9d1fdce77a
3 changed files with 24 additions and 19 deletions

View File

@@ -16,6 +16,7 @@ import gq.kirmanak.mealient.database.recipe.entity.RecipeSummaryEntity
import gq.kirmanak.mealient.datasource.v0.models.* import gq.kirmanak.mealient.datasource.v0.models.*
import gq.kirmanak.mealient.datasource.v1.models.* import gq.kirmanak.mealient.datasource.v1.models.*
import gq.kirmanak.mealient.datastore.recipe.AddRecipeDraft import gq.kirmanak.mealient.datastore.recipe.AddRecipeDraft
import java.util.*
fun FullRecipeInfo.toRecipeEntity() = RecipeEntity( fun FullRecipeInfo.toRecipeEntity() = RecipeEntity(
remoteId = remoteId, remoteId = remoteId,
@@ -161,10 +162,12 @@ private fun AddRecipeSettingsInfo.toV1Settings() = AddRecipeSettingsV1(
) )
private fun AddRecipeIngredientInfo.toV1Ingredient() = AddRecipeIngredientV1( private fun AddRecipeIngredientInfo.toV1Ingredient() = AddRecipeIngredientV1(
id = UUID.randomUUID().toString(),
note = note, note = note,
) )
private fun AddRecipeInstructionInfo.toV1Instruction() = AddRecipeInstructionV1( private fun AddRecipeInstructionInfo.toV1Instruction() = AddRecipeInstructionV1(
id = UUID.randomUUID().toString(),
text = text, text = text,
ingredientReferences = emptyList(), ingredientReferences = emptyList(),
) )

View File

@@ -5,26 +5,26 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class AddRecipeRequestV0( data class AddRecipeRequestV0(
@SerialName("name") val name: String = "", @SerialName("name") val name: String,
@SerialName("description") val description: String = "", @SerialName("description") val description: String,
@SerialName("recipeYield") val recipeYield: String = "", @SerialName("recipeYield") val recipeYield: String,
@SerialName("recipeIngredient") val recipeIngredient: List<AddRecipeIngredientV0> = emptyList(), @SerialName("recipeIngredient") val recipeIngredient: List<AddRecipeIngredientV0>,
@SerialName("recipeInstructions") val recipeInstructions: List<AddRecipeInstructionV0> = emptyList(), @SerialName("recipeInstructions") val recipeInstructions: List<AddRecipeInstructionV0>,
@SerialName("settings") val settings: AddRecipeSettingsV0 = AddRecipeSettingsV0(), @SerialName("settings") val settings: AddRecipeSettingsV0,
) )
@Serializable @Serializable
data class AddRecipeIngredientV0( data class AddRecipeIngredientV0(
@SerialName("note") val note: String = "", @SerialName("note") val note: String,
) )
@Serializable @Serializable
data class AddRecipeInstructionV0( data class AddRecipeInstructionV0(
@SerialName("text") val text: String = "", @SerialName("text") val text: String,
) )
@Serializable @Serializable
data class AddRecipeSettingsV0( data class AddRecipeSettingsV0(
@SerialName("disableComments") val disableComments: Boolean = false, @SerialName("disableComments") val disableComments: Boolean,
@SerialName("public") val public: Boolean = true, @SerialName("public") val public: Boolean,
) )

View File

@@ -5,26 +5,28 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class UpdateRecipeRequestV1( data class UpdateRecipeRequestV1(
@SerialName("description") val description: String = "", @SerialName("description") val description: String,
@SerialName("recipeYield") val recipeYield: String = "", @SerialName("recipeYield") val recipeYield: String,
@SerialName("recipeIngredient") val recipeIngredient: List<AddRecipeIngredientV1> = emptyList(), @SerialName("recipeIngredient") val recipeIngredient: List<AddRecipeIngredientV1>,
@SerialName("recipeInstructions") val recipeInstructions: List<AddRecipeInstructionV1> = emptyList(), @SerialName("recipeInstructions") val recipeInstructions: List<AddRecipeInstructionV1>,
@SerialName("settings") val settings: AddRecipeSettingsV1 = AddRecipeSettingsV1(), @SerialName("settings") val settings: AddRecipeSettingsV1,
) )
@Serializable @Serializable
data class AddRecipeIngredientV1( data class AddRecipeIngredientV1(
@SerialName("note") val note: String = "", @SerialName("referenceId") val id: String,
@SerialName("note") val note: String,
) )
@Serializable @Serializable
data class AddRecipeInstructionV1( data class AddRecipeInstructionV1(
@SerialName("id") val id: String,
@SerialName("text") val text: String = "", @SerialName("text") val text: String = "",
@SerialName("ingredientReferences") val ingredientReferences: List<String> = emptyList(), @SerialName("ingredientReferences") val ingredientReferences: List<String>,
) )
@Serializable @Serializable
data class AddRecipeSettingsV1( data class AddRecipeSettingsV1(
@SerialName("disableComments") val disableComments: Boolean = false, @SerialName("disableComments") val disableComments: Boolean,
@SerialName("public") val public: Boolean = true, @SerialName("public") val public: Boolean,
) )