From 06060eca8980f9ef449177de5b3f0c7288bec668 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Tue, 9 Mar 2021 20:17:22 -0500 Subject: [PATCH] =?UTF-8?q?L'=C3=A9chantillon=20d'une=20recette=20n'est=20?= =?UTF-8?q?plus=20obligatoire.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../colorrecipesexplorer/model/Recipe.kt | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/model/Recipe.kt b/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/model/Recipe.kt index 4b904c1..3180f4e 100644 --- a/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/model/Recipe.kt +++ b/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/model/Recipe.kt @@ -29,7 +29,7 @@ data class Recipe( val description: String, - val sample: Int, + val sample: Int?, @Column(name = "approbation_date") val approbationDate: LocalDate?, @@ -106,9 +106,8 @@ open class RecipeSaveDto( @field:NotBlank(message = RECIPE_DESCRIPTION_NULL_MESSAGE) val description: String, - @field:NotNull(message = RECIPE_SAMPLE_NULL_MESSAGE) @field:Min(value = 0, message = RECIPE_SAMPLE_TOO_SMALL_MESSAGE) - val sample: Int, + val sample: Int?, val approbationDate: LocalDate?, @@ -145,24 +144,14 @@ open class RecipeUpdateDto( val remark: String?, val steps: List? -) : EntityDto { - override fun toEntity(): Recipe = recipe( - id, - name = name ?: "name", - description = description ?: "description", - sample = sample ?: -1, - approbationDate = approbationDate ?: LocalDate.MIN, - remark = remark ?: "remark", - steps = steps?.toMutableList() ?: mutableListOf() - ) -} +) : EntityDto // ==== DSL ==== fun recipe( id: Long? = null, name: String = "name", description: String = "description", - sample: Int = -1, + sample: Int? = -1, approbationDate: LocalDate? = LocalDate.MIN, remark: String = "remark", note: String = "", @@ -182,7 +171,7 @@ fun recipePublicDataDto( fun recipeSaveDto( name: String = "name", description: String = "description", - sample: Int = -1, + sample: Int? = -1, approbationDate: LocalDate? = LocalDate.MIN, remark: String = "remark", companyId: Long = 0L, @@ -191,11 +180,11 @@ fun recipeSaveDto( fun recipeUpdateDto( id: Long = 0L, - name: String = "name", - description: String = "description", - sample: Int = -1, + name: String? = "name", + description: String? = "description", + sample: Int? = -1, approbationDate: LocalDate? = LocalDate.MIN, remark: String? = "remark", - steps: List = listOf(), + steps: List? = listOf(), op: RecipeUpdateDto.() -> Unit = {} ) = RecipeUpdateDto(id, name, description, sample, approbationDate, remark, steps).apply(op)