From 3987b18fdd3c131bbb5635fe16c3a785ec868445 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Fri, 26 Mar 2021 15:46:47 -0400 Subject: [PATCH] =?UTF-8?q?Correction=20d'un=20bug=20qui=20emp=C3=AAchait?= =?UTF-8?q?=20de=20modifier=20les=20=C3=A9tapes=20d'une=20recette.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dev/fyloz/colorrecipesexplorer/model/Recipe.kt | 4 ++-- .../fyloz/colorrecipesexplorer/service/RecipeService.kt | 9 +++++++-- src/main/resources/application-mysql.properties | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/dev/fyloz/colorrecipesexplorer/model/Recipe.kt b/src/main/kotlin/dev/fyloz/colorrecipesexplorer/model/Recipe.kt index 9eb1c86..bac32a1 100644 --- a/src/main/kotlin/dev/fyloz/colorrecipesexplorer/model/Recipe.kt +++ b/src/main/kotlin/dev/fyloz/colorrecipesexplorer/model/Recipe.kt @@ -146,7 +146,7 @@ data class RecipeGroupInformation( @OneToMany(cascade = [CascadeType.ALL], fetch = FetchType.EAGER, orphanRemoval = true) @JoinColumn(name = "recipe_group_information_id") - var steps: Set? + var steps: MutableSet? ) data class RecipeStepsDto( @@ -230,7 +230,7 @@ fun recipeGroupInformation( id: Long? = null, group: EmployeeGroup = employeeGroup(), note: String? = null, - steps: Set? = setOf(), + steps: MutableSet? = mutableSetOf(), op: RecipeGroupInformation.() -> Unit = {} ) = RecipeGroupInformation(id, group, note, steps).apply(op) diff --git a/src/main/kotlin/dev/fyloz/colorrecipesexplorer/service/RecipeService.kt b/src/main/kotlin/dev/fyloz/colorrecipesexplorer/service/RecipeService.kt index baf0049..0f35fe8 100644 --- a/src/main/kotlin/dev/fyloz/colorrecipesexplorer/service/RecipeService.kt +++ b/src/main/kotlin/dev/fyloz/colorrecipesexplorer/service/RecipeService.kt @@ -86,10 +86,15 @@ class RecipeServiceImpl( with(recipe.groupInformationForGroup(it.groupId)) { updatedGroupsInformation.add( this?.apply { - this.steps = it.steps + if (this.steps != null) { + this.steps!!.clear() + this.steps!!.addAll(it.steps) + } else { + this.steps = it.steps.toMutableSet() + } } ?: recipeGroupInformation( group = groupService.getById(it.groupId), - steps = it.steps + steps = it.steps.toMutableSet() ) ) } diff --git a/src/main/resources/application-mysql.properties b/src/main/resources/application-mysql.properties index 9226777..06d0241 100644 --- a/src/main/resources/application-mysql.properties +++ b/src/main/resources/application-mysql.properties @@ -1,4 +1,4 @@ -spring.datasource.url=jdbc:mysql://172.66.1.1/updater +spring.datasource.url=jdbc:mysql://172.66.1.1/cre spring.datasource.username=root spring.datasource.password=pass spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver