diff --git a/src/main/java/zipdabang/server/converter/RecipeConverter.java b/src/main/java/zipdabang/server/converter/RecipeConverter.java index c60f4fb..3449456 100644 --- a/src/main/java/zipdabang/server/converter/RecipeConverter.java +++ b/src/main/java/zipdabang/server/converter/RecipeConverter.java @@ -747,7 +747,7 @@ public static TestRecipe toTestRecipe(RecipeRequestDto.CreateRecipeDto request, } public static List toTestRecipeCategory(List categoryIds, TestRecipe recipe) { - return categoryIds.stream() + return categoryIds.stream().parallel() .map(recipeCategoryId -> toTestRecipeCategoryMappingDto(recipeCategoryId, recipe)) .collect(Collectors.toList()); } @@ -760,7 +760,7 @@ private static TestRecipeCategoryMapping toTestRecipeCategoryMappingDto(Long cat } public static List toTestStep(RecipeRequestDto.CreateRecipeDto request, TestRecipe recipe, List stepImages) { - return request.getSteps().stream() + return request.getSteps().stream().parallel() .map(step-> { if (step.getDescription() == null) throw new RecipeException(CommonStatus.NULL_RECIPE_ERROR); @@ -801,7 +801,7 @@ private static TestStep toTestStepDto(RecipeRequestDto.StepDto step, TestRecipe } public static List toTestIngredient(RecipeRequestDto.CreateRecipeDto request, TestRecipe recipe) { - return request.getIngredients().stream() + return request.getIngredients().stream().parallel() .map(ingredient -> toTestIngredientDto(ingredient, recipe)) .collect(Collectors.toList()); } diff --git a/src/main/java/zipdabang/server/service/serviceImpl/RecipeServiceImpl.java b/src/main/java/zipdabang/server/service/serviceImpl/RecipeServiceImpl.java index 26f6891..bf737aa 100644 --- a/src/main/java/zipdabang/server/service/serviceImpl/RecipeServiceImpl.java +++ b/src/main/java/zipdabang/server/service/serviceImpl/RecipeServiceImpl.java @@ -938,7 +938,7 @@ public TestRecipe getTestRecipe(Long recipeId) { return findRecipe; } - @Transactional(readOnly = false) + @Transactional @Override public Page testRecipeListByCategory(Long categoryId, Integer pageIndex, String order) { @@ -970,16 +970,17 @@ public Page testRecipeListByCategory(Long categoryId, Integer pageIn public Boolean deleteTestRecipe() { List findRecipes = testRecipeRepository.findAll(); - List thumbnailUrls = findRecipes.stream().map(recipe -> recipe.getThumbnailUrl()).collect(Collectors.toList()); - List stepUrlList = testStepRepository.findAll().stream() + List thumbnailUrls = findRecipes.stream().parallel() + .map(recipe -> recipe.getThumbnailUrl()).collect(Collectors.toList()); + List stepUrlList = testStepRepository.findAll().stream().parallel() .filter(steps -> steps.getImageUrl() != null) .map(step -> step.getImageUrl()) .collect(Collectors.toList()); testRecipeRepository.deleteAll(); - thumbnailUrls.forEach(thumbnailUrl -> amazonS3Manager.deleteFile(RecipeConverter.toKeyName(thumbnailUrl).substring(1))); - stepUrlList + thumbnailUrls.parallelStream().forEach(thumbnailUrl -> amazonS3Manager.deleteFile(RecipeConverter.toKeyName(thumbnailUrl).substring(1))); + stepUrlList.parallelStream() .forEach(stepUrl -> amazonS3Manager.deleteFile(RecipeConverter.toKeyName(stepUrl).substring(1))); return testRecipeRepository.count() == 0;