diff --git a/src/main/java/zipdabang/server/converter/RecipeConverter.java b/src/main/java/zipdabang/server/converter/RecipeConverter.java index 933e54d..c60f4fb 100644 --- a/src/main/java/zipdabang/server/converter/RecipeConverter.java +++ b/src/main/java/zipdabang/server/converter/RecipeConverter.java @@ -44,7 +44,6 @@ public class RecipeConverter { private static AmazonS3Manager staticAmazonS3Manager; private static TimeConverter staticTimeConverter; - private static RecipeService staticRecipeService; diff --git a/src/main/java/zipdabang/server/repository/testRepository/testRecipeRepositoryCustom/TestRecipeRepositoryCustom.java b/src/main/java/zipdabang/server/repository/testRepository/testRecipeRepositoryCustom/TestRecipeRepositoryCustom.java index d65ec38..62ec1fa 100644 --- a/src/main/java/zipdabang/server/repository/testRepository/testRecipeRepositoryCustom/TestRecipeRepositoryCustom.java +++ b/src/main/java/zipdabang/server/repository/testRepository/testRecipeRepositoryCustom/TestRecipeRepositoryCustom.java @@ -8,6 +8,7 @@ public interface TestRecipeRepositoryCustom { + BooleanExpression recipesInCategoryCondition(Long categoryId); List testRecipesOrderBy(Integer pageIndex, Integer pageSize, String order, BooleanExpression... booleanExpressions); Long testRecipeTotalCount(BooleanExpression... booleanExpressions); diff --git a/src/main/java/zipdabang/server/repository/testRepository/testRecipeRepositoryImpl/TestRecipeRepositoryImpl.java b/src/main/java/zipdabang/server/repository/testRepository/testRecipeRepositoryImpl/TestRecipeRepositoryImpl.java index bce3534..b584813 100644 --- a/src/main/java/zipdabang/server/repository/testRepository/testRecipeRepositoryImpl/TestRecipeRepositoryImpl.java +++ b/src/main/java/zipdabang/server/repository/testRepository/testRecipeRepositoryImpl/TestRecipeRepositoryImpl.java @@ -6,13 +6,16 @@ import lombok.extern.slf4j.Slf4j; import zipdabang.server.domain.member.Member; import zipdabang.server.domain.test.QTestRecipe; +import zipdabang.server.domain.test.QTestRecipeCategoryMapping; import zipdabang.server.domain.test.TestRecipe; import zipdabang.server.repository.testRepository.testRecipeRepositoryCustom.TestRecipeRepositoryCustom; import java.util.List; import static zipdabang.server.domain.recipe.QRecipe.recipe; +import static zipdabang.server.domain.recipe.QRecipeCategoryMapping.recipeCategoryMapping; import static zipdabang.server.domain.test.QTestRecipe.testRecipe; +import static zipdabang.server.domain.test.QTestRecipeCategoryMapping.testRecipeCategoryMapping; @Slf4j @RequiredArgsConstructor @@ -20,6 +23,16 @@ public class TestRecipeRepositoryImpl implements TestRecipeRepositoryCustom { private final JPAQueryFactory queryFactory; QTestRecipe qTestRecipe = testRecipe; + QTestRecipeCategoryMapping qTestRecipeCategoryMapping = testRecipeCategoryMapping; + + @Override + public BooleanExpression recipesInCategoryCondition(Long categoryId) { + return testRecipe.in(queryFactory + .select(testRecipeCategoryMapping.recipe) + .from(testRecipeCategoryMapping) + .where(testRecipeCategoryMapping.category.id.eq(categoryId)) + .fetch()); + } @Override public List testRecipesOrderBy(Integer pageIndex, Integer pageSize, String order, BooleanExpression... booleanExpressions) { @@ -36,7 +49,7 @@ public List testRecipesOrderBy(Integer pageIndex, Integer pageSize, return queryFactory .selectFrom(testRecipe) - .orderBy(recipe.createdAt.desc()) + .orderBy(testRecipe.createdAt.desc()) .offset(pageIndex * pageSize) .limit(pageSize) .fetch(); @@ -56,8 +69,8 @@ public Long testRecipeTotalCount(BooleanExpression... booleanExpressions) { } return queryFactory - .select(recipe.count()) - .from(recipe) + .select(testRecipe.count()) + .from(testRecipe) .where( combinedExpression ) diff --git a/src/main/java/zipdabang/server/service/serviceImpl/RecipeServiceImpl.java b/src/main/java/zipdabang/server/service/serviceImpl/RecipeServiceImpl.java index 8f8359b..26f6891 100644 --- a/src/main/java/zipdabang/server/service/serviceImpl/RecipeServiceImpl.java +++ b/src/main/java/zipdabang/server/service/serviceImpl/RecipeServiceImpl.java @@ -949,7 +949,7 @@ public Page testRecipeListByCategory(Long categoryId, Integer pageIn List content = new ArrayList<>(); - BooleanExpression whereCondition = recipeRepositoryCustom.recipesInCategoryCondition(categoryId); + BooleanExpression whereCondition = testRecipeRepositoryCustom.recipesInCategoryCondition(categoryId); content = testRecipeRepositoryCustom.testRecipesOrderBy(pageIndex,pageSize, order, whereCondition);