Mise à jour de RecipeUpdateDto

This commit is contained in:
FyloZ 2021-01-20 22:31:42 -05:00
parent b47b8d0df5
commit 04e7049e2e
3 changed files with 5 additions and 12 deletions

View File

@ -121,10 +121,6 @@ open class RecipeUpdateDto(
val remark: String? = "remark",
val note: String? = "note",
val company: Company? = company(),
val steps: List<RecipeStep>? = listOf()
) : EntityDto<Recipe> {
override fun toEntity(): Recipe = recipe(
@ -134,8 +130,6 @@ open class RecipeUpdateDto(
sample = sample ?: -1,
approbationDate = approbationDate ?: LocalDate.MIN,
remark = remark ?: "remark",
note = note ?: "note",
company = company ?: company(),
steps = steps ?: listOf()
)
}
@ -172,8 +166,6 @@ fun recipeUpdateDto(
sample: Int = -1,
approbationDate: LocalDate? = LocalDate.MIN,
remark: String? = "remark",
note: String? = "note",
company: Company = company(),
steps: List<RecipeStep> = listOf(),
op: RecipeUpdateDto.() -> Unit = {}
) = RecipeUpdateDto(id, name, description, sample, approbationDate, remark, note, company, steps).apply(op)
) = RecipeUpdateDto(id, name, description, sample, approbationDate, remark, steps).apply(op)

View File

@ -46,8 +46,9 @@ class RecipeServiceImpl(recipeRepository: RecipeRepository, val companyService:
sample = if (sample != null && sample >= 0) sample else persistedRecipe.sample,
approbationDate = approbationDate ?: persistedRecipe.approbationDate,
remark = remark.or(persistedRecipe.remark),
note = note.or(persistedRecipe.note),
company = company ?: persistedRecipe.company,
note = persistedRecipe.note,
company = persistedRecipe.company,
mixes = persistedRecipe.mixes,
steps = if (!steps.isNullOrEmpty()) steps else persistedRecipe.steps
)
})

View File

@ -22,7 +22,7 @@ class RecipeServiceTest :
override val entity: Recipe = recipe(id = 0L, name = "recipe", company = company)
override val anotherEntity: Recipe = recipe(id = 1L, name = "another recipe", company = company)
override val entitySaveDto: RecipeSaveDto = spy(recipeSaveDto(name = entity.name, companyId = entity.company.id!!))
override val entityUpdateDto: RecipeUpdateDto = spy(recipeUpdateDto(id = entity.id!!, name = entity.name, company = entity.company))
override val entityUpdateDto: RecipeUpdateDto = spy(recipeUpdateDto(id = entity.id!!, name = entity.name))
@Nested
inner class ExistsByCompany {