Correction: Un message d'erreur apparaissait lors de la suppression d'une entité, même si l'opération se terminait avec succès.

This commit is contained in:
FyloZ 2020-03-10 09:03:30 -04:00
parent f07c1c71db
commit f091cf7fd7
8 changed files with 16 additions and 18 deletions

View File

@ -5,6 +5,7 @@ import dev.fyloz.trial.colorrecipesexplorer.core.exception.model.EntityNotFoundE
import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ModelResponseBuilder;
import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ResponseCode;
import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ResponseDataType;
import dev.fyloz.trial.colorrecipesexplorer.core.model.Company;
import dev.fyloz.trial.colorrecipesexplorer.core.services.model.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -39,9 +40,9 @@ public class CompanyRemoverController {
ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder("");
try {
companyService.deleteById(id);
modelResponseBuilder.addResponseCode(ResponseCode.SUCCESS_DELETING_COMPANY, companyService.getById(id).getName());
Company company = companyService.getById(id);
companyService.delete(company);
modelResponseBuilder.addResponseCode(ResponseCode.SUCCESS_DELETING_COMPANY, company.getName());
} catch (EntityLinkedException ex) {
modelResponseBuilder.addResponseCode(ResponseCode.COMPANY_LINKED, companyService.getById(id).getName());
} catch (EntityNotFoundException ex) {

View File

@ -43,9 +43,9 @@ public class MaterialRemoverController {
ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder();
try {
materialService.deleteById(id);
modelResponseBuilder.addResponseCode(ResponseCode.SUCCESS_DELETING_MATERIAL, materialService.getById(id).getName());
Material material = materialService.getById(id);
materialService.delete(material);
modelResponseBuilder.addResponseCode(ResponseCode.SUCCESS_DELETING_MATERIAL, material.getName());
} catch (EntityLinkedException ex) {
modelResponseBuilder.addResponseCode(ResponseCode.MATERIAL_LINKED, materialService.getById(id).getName());
} catch (EntityNotFoundException ex) {

View File

@ -44,9 +44,9 @@ public class MaterialTypeRemoverController {
ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder();
try {
materialTypeService.deleteById(id);
modelResponseBuilder.addResponseCode(ResponseCode.SUCCESS_DELETING_MATERIAL_TYPE, materialTypeService.getById(id).getName());
MaterialType materialType = materialTypeService.getById(id);
materialTypeService.delete(materialType);
modelResponseBuilder.addResponseCode(ResponseCode.SUCCESS_DELETING_MATERIAL_TYPE, materialType.getName());
} catch (EntityLinkedException ex) {
modelResponseBuilder.addResponseCode(ResponseCode.MATERIAL_TYPE_LINKED, materialTypeService.getById(id).getName());
} catch (EntityNotFoundException ex) {

View File

@ -28,7 +28,6 @@ public class MixRemoverController {
try {
Mix mix = mixService.getById(id);
mixService.delete(mix);
return modelResponseBuilder
.withRedirect(EDITOR_RECIPE_SPECIFIC, mix.getRecipe().getId())
.build();

View File

@ -4,6 +4,7 @@ import dev.fyloz.trial.colorrecipesexplorer.core.exception.model.EntityNotFoundE
import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ModelResponseBuilder;
import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ResponseCode;
import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ResponseDataType;
import dev.fyloz.trial.colorrecipesexplorer.core.model.Recipe;
import dev.fyloz.trial.colorrecipesexplorer.core.services.model.RecipeService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@ -36,9 +37,9 @@ public class RecipeRemoverController {
ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder();
try {
recipeService.deleteById(id);
modelResponseBuilder.addResponseCode(ResponseCode.SUCCESS_DELETING_RECIPE, recipeService.getById(id).getName());
Recipe recipe = recipeService.getById(id);
recipeService.delete(recipe);
modelResponseBuilder.addResponseCode(ResponseCode.SUCCESS_DELETING_RECIPE, recipe.getName());
} catch (EntityNotFoundException ex) {
modelResponseBuilder.addResponseCode(ResponseCode.RECIPE_NOT_FOUND, id);
}

View File

@ -24,9 +24,6 @@
<!-- Corps de la page -->
<section>
<div th:include="fragments.html :: messages"></div>
<p class="success" th:if="${name != null}"
th:text="#{company.success.deleted(${name})}"></b>
</p>
<h1 th:text="#{company.delete.title}"></h1>
<form action="/company/remover/" class="requireAuth-remover" method="POST">

View File

@ -21,8 +21,6 @@
<!-- Corps de la page -->
<section>
<div th:include="fragments.html :: messages"></div>
<p class="success" th:if="${name != null}"
th:text="#{materialType.success.deleted(${name})}"></p>
<h1 th:text="#{materialType.delete.title}"></h1>
<form th:action="@{/materialType/remover/}" class="requireAuth-remover" method="POST">

View File

@ -9,6 +9,8 @@
* L'indicateur de statut de l'extension bPac ne s'actualisait parfois pas.
* Aucun message d'erreur ne pouvait s'afficher lors de la création d'un mélange.
* Les recettes n'étaient pas mises à jour lors de leur édition.
* Les quantités n'étaient pas correctement converties en millilitres.
* Un message d'erreur apparaissait lors de la suppression d'une entité, même si l'opération se terminait avec succès.
# v1.3.0 (Optimisations back-end)
### Note: Cette mise à jour n'est pas compatible avec les anciennes versions.