Set up parent category mechanism.

This commit is contained in:
Florian THIERRY
2024-03-12 18:20:04 +01:00
parent a3295636b4
commit ed766d4c8c
8 changed files with 64 additions and 15 deletions

View File

@@ -68,11 +68,14 @@ public class CategoryUseCases {
}
if (!isNull(subCategoryIds)) {
List<Category> subCategories;
try {
subCategories = categoryPort.findAllByIds(subCategoryIds);
} catch (CategoryNotFoundException exception) {
throw new CategoryEditionException(exception);
List<Category> subCategories = emptyList();
if (!subCategoryIds.isEmpty()) {
try {
subCategories = categoryPort.findAllByIds(subCategoryIds);
} catch (CategoryNotFoundException exception) {
throw new CategoryEditionException(exception);
}
}
categoryBuilder.withSubCategories(subCategories);
}
@@ -93,4 +96,8 @@ public class CategoryUseCases {
categoryPort.deleteById(categoryId);
}
public List<Category> getAll() {
return categoryPort.findAll();
}
}