Skip to content

Commit

Permalink
โ™ป๏ธ change return type
Browse files Browse the repository at this point in the history
  • Loading branch information
tackyu committed Jan 6, 2025
1 parent 00195da commit 05d9f95
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.pengcook.authentication.resolver.LoginUser;
import net.pengcook.recipe.dto.PageRecipeRequest;
import net.pengcook.recipe.dto.RecipeDescriptionResponse;
import net.pengcook.recipe.dto.RecipeHomeResponse;
import net.pengcook.recipe.dto.RecipeHomeWithMineResponse;
import net.pengcook.recipe.dto.RecipeHomeWithMineResponseV1;
import net.pengcook.recipe.dto.RecipeRequest;
Expand Down Expand Up @@ -63,7 +62,7 @@ public List<RecipeHomeWithMineResponseV1> readLikeRecipesV1(@LoginUser UserInfo
}

@GetMapping("/follows")
public List<RecipeHomeResponse> readFollowRecipes(
public List<RecipeHomeWithMineResponseV1> readFollowRecipes(
@LoginUser UserInfo userInfo,
@ModelAttribute @Valid PageRecipeRequest pageRecipeRequest
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ public List<RecipeHomeWithMineResponseV1> readLikeRecipesV1(UserInfo userInfo) {
}

@Transactional(readOnly = true)
public List<RecipeHomeResponse> readFollowRecipes(UserInfo userInfo, PageRecipeRequest pageRecipeRequest) {
public List<RecipeHomeWithMineResponseV1> readFollowRecipes(UserInfo userInfo,
PageRecipeRequest pageRecipeRequest) {
List<UserFollow> followings = userFollowRepository.findAllByFollowerId(userInfo.getId());
List<Long> followeeIds = followings.stream()
.map(userFollow -> userFollow.getFollowee().getId())
Expand All @@ -163,7 +164,8 @@ public List<RecipeHomeResponse> readFollowRecipes(UserInfo userInfo, PageRecipeR
.toList();

return recipeRepository.findRecipeDataV1(recipeIds).stream()
.sorted(Comparator.comparing(RecipeHomeResponse::recipeId).reversed())
.map(recipeHomeResponse -> new RecipeHomeWithMineResponseV1(userInfo, recipeHomeResponse))
.sorted(Comparator.comparing(RecipeHomeWithMineResponseV1::recipeId).reversed())
.toList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
import net.pengcook.RestDocsSetting;
import net.pengcook.authentication.annotation.WithLoginUser;
import net.pengcook.authentication.annotation.WithLoginUserTest;
import net.pengcook.category.dto.CategoryResponse;
import net.pengcook.ingredient.domain.Requirement;
import net.pengcook.ingredient.dto.IngredientCreateRequest;
import net.pengcook.recipe.dto.AuthorResponse;
import net.pengcook.category.dto.CategoryResponse;
import net.pengcook.ingredient.dto.IngredientResponse;
import net.pengcook.recipe.dto.AuthorResponse;
import net.pengcook.recipe.dto.RecipeDescriptionResponse;
import net.pengcook.recipe.dto.RecipeHomeResponse;
import net.pengcook.recipe.dto.RecipeHomeWithMineResponse;
import net.pengcook.recipe.dto.RecipeHomeWithMineResponseV1;
import net.pengcook.recipe.dto.RecipeRequest;
Expand Down Expand Up @@ -271,13 +270,15 @@ void readFollowRecipes() {
fieldWithPath("[]").description("๋ ˆ์‹œํ”ผ ๋ชฉ๋ก"),
fieldWithPath("[].recipeId").description("๋ ˆ์‹œํ”ผ ์•„์ด๋””"),
fieldWithPath("[].title").description("๋ ˆ์‹œํ”ผ ์ œ๋ชฉ"),
fieldWithPath("[].authorId").description("์ž‘์„ฑ์ž ์•„์ด๋””"),
fieldWithPath("[].authorName").description("์ž‘์„ฑ์ž ์ด๋ฆ„"),
fieldWithPath("[].authorImage").description("์ž‘์„ฑ์ž ์ด๋ฏธ์ง€"),
fieldWithPath("[].author").description("์ž‘์„ฑ์ž ์ •๋ณด"),
fieldWithPath("[].author.authorId").description("์ž‘์„ฑ์ž ์•„์ด๋””"),
fieldWithPath("[].author.authorName").description("์ž‘์„ฑ์ž ์ด๋ฆ„"),
fieldWithPath("[].author.authorImage").description("์ž‘์„ฑ์ž ์ด๋ฏธ์ง€"),
fieldWithPath("[].thumbnail").description("์ธ๋„ค์ผ ์ด๋ฏธ์ง€"),
fieldWithPath("[].likeCount").description("์ข‹์•„์š” ์ˆ˜"),
fieldWithPath("[].commentCount").description("๋Œ“๊ธ€ ์ˆ˜"),
fieldWithPath("[].createdAt").description("๋ ˆ์‹œํ”ผ ์ƒ์„ฑ์ผ์‹œ")
fieldWithPath("[].createdAt").description("๋ ˆ์‹œํ”ผ ์ƒ์„ฑ์ผ์‹œ"),
fieldWithPath("[].mine").description("์กฐํšŒ์ž ์ž‘์„ฑ ์—ฌ๋ถ€")
)))
.queryParam("pageNumber", 0)
.queryParam("pageSize", 5)
Expand All @@ -287,7 +288,7 @@ void readFollowRecipes() {
.body("size()", is(3))
.extract()
.jsonPath()
.getList(".", RecipeHomeResponse.class);
.getList(".", RecipeHomeWithMineResponseV1.class);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.pengcook.ingredient.dto.IngredientCreateRequest;
import net.pengcook.recipe.domain.Recipe;
import net.pengcook.recipe.dto.PageRecipeRequest;
import net.pengcook.recipe.dto.RecipeHomeResponse;
import net.pengcook.recipe.dto.RecipeHomeWithMineResponseV1;
import net.pengcook.recipe.dto.RecipeRequest;
import net.pengcook.recipe.dto.RecipeResponse;
Expand Down Expand Up @@ -85,11 +84,11 @@ void readFollowRecipes() {
UserInfo userInfo = new UserInfo(1L, "[email protected]");
PageRecipeRequest pageRecipeRequest = new PageRecipeRequest(0, 10, null, null, null);

List<RecipeHomeResponse> actual = recipeService.readFollowRecipes(userInfo, pageRecipeRequest);
List<RecipeHomeWithMineResponseV1> actual = recipeService.readFollowRecipes(userInfo, pageRecipeRequest);

assertAll(
() -> assertThat(actual).hasSize(3),
() -> assertThat(actual).extracting("authorId").containsOnly(4L),
() -> assertThat(actual).extracting("author.authorId").containsOnly(4L),
() -> assertThat(actual).extracting("recipeId")
.containsExactly(18L, 17L, 16L)
);
Expand Down

0 comments on commit 05d9f95

Please sign in to comment.