Skip to content

Commit

Permalink
Merge pull request #109 from Recipe-Project/feature/fix_order_paramet…
Browse files Browse the repository at this point in the history
…er_name

refactor: 레시피 조회 시 정렬값을 views, scraps, newest로 통일하도록 수정
  • Loading branch information
joona95 authored Oct 13, 2024
2 parents 0d1ec19 + 53196b5 commit fe282a7
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ dependencies {
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-impl', version: '0.11.2'
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: '0.11.2'

implementation 'org.jsoup:jsoup:1.13.1'
implementation 'org.jsoup:jsoup:1.18.1'

implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.2.2'
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '5.0.0-alpha.14'

implementation group: 'com.google.api-client', name: 'google-api-client', version: '1.25.0'
implementation group: 'com.google.apis', name: 'google-api-services-youtube', version: 'v3-rev212-1.25.0'
Expand All @@ -64,7 +64,7 @@ dependencies {

implementation 'org.springframework.boot:spring-boot-starter-data-redis'

implementation 'org.springframework.cloud:spring-cloud-starter-openfeign:4.1.0'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '4.1.3'

implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public RecipesResponse getBlogRecipes(@Parameter(hidden = true) User user,
@RequestParam(value = "startAfter") long startAfter,
@Parameter(example = "20", name = "사이즈")
@RequestParam(value = "size") int size,
@Parameter(example = "조회수순(blogViews) / 좋아요순(blogScraps) / 최신순(newest) = 기본값", name = "정렬")
@Parameter(example = "조회수순(views) / 좋아요순(scraps) / 최신순(newest) = 기본값", name = "정렬")
@RequestParam(value = "sort") String sort) {

return blogRecipeService.findBlogRecipesByKeyword(user, keyword, startAfter, size, sort);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public RecipesResponse getRecipes(@Parameter(hidden = true) User user,
@RequestParam(value = "startAfter") long startAfter,
@Parameter(example = "20", name = "사이즈")
@RequestParam(value = "size") int size,
@Parameter(example = "조회수순(recipeViews) / 좋아요순(recipeScraps) / 최신순(newest) = 기본값", name = "정렬")
@Parameter(example = "조회수순(views) / 좋아요순(scraps) / 최신순(newest) = 기본값", name = "정렬")
@RequestParam(value = "sort") String sort) {

return recipeSearchService.findRecipesByKeywordOrderBy(user, keyword, startAfter, size, sort);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public RecipesResponse getYoutubeRecipes(@Parameter(hidden = true) User user,
@RequestParam(value = "startAfter") long startAfter,
@Parameter(example = "20", name = "사이즈")
@RequestParam(value = "size") int size,
@Parameter(example = "조회수순(youtubeViews) / 좋아요순(youtubeScraps) / 최신순(newest) = 기본값", name = "정렬")
@Parameter(example = "조회수순(views) / 좋아요순(scraps) / 최신순(newest) = 기본값", name = "정렬")
@RequestParam(value = "sort") String sort) throws IOException {

return youtubeRecipeService.findYoutubeRecipesByKeyword(user, keyword, startAfter, size, sort);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public RecipesResponse findRecipesByKeywordOrderBy(User user, String keyword, lo
long totalCnt = recipeRepository.countByKeyword(keyword);

List<Recipe> recipes;
if (sort.equals("recipeScraps")) {
if (sort.equals("scraps")) {
recipes = findByKeywordOrderByRecipeScrapCnt(keyword, lastRecipeId, size);
} else if (sort.equals("recipeViews")) {
} else if (sort.equals("views")) {
recipes = findByKeywordOrderByRecipeViewCnt(keyword, lastRecipeId, size);
} else {
recipes = findByKeywordOrderByCreatedAt(keyword, lastRecipeId, size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public RecipesResponse findBlogRecipesByKeyword(User user, String keyword, long
@Transactional(readOnly = true)
public List<BlogRecipe> findByKeywordOrderBy(String keyword, long lastBlogRecipeId, int size, String sort) {

if (sort.equals("blogScraps")) {
if (sort.equals("scraps")) {
return findByKeywordOrderByBlogScrapCnt(keyword, lastBlogRecipeId, size);
} else if (sort.equals("blogViews")) {
} else if (sort.equals("views")) {
return findByKeywordOrderByBlogViewCnt(keyword, lastBlogRecipeId, size);
} else {
return findByKeywordOrderByPublishedAt(keyword, lastBlogRecipeId, size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public RecipesResponse findYoutubeRecipesByKeyword(User user, String keyword, lo
@Transactional(readOnly = true)
public List<YoutubeRecipe> findByKeywordOrderBy(String keyword, long lastYoutubeRecipeId, int size, String sort) {

if (sort.equals("youtubeScraps")) {
if (sort.equals("scraps")) {
return findByKeywordOrderByYoutubeScrapCnt(keyword, lastYoutubeRecipeId, size);
} else if (sort.equals("youtubeViews")) {
} else if (sort.equals("views")) {
return findByKeywordOrderByYoutubeViewCnt(keyword, lastYoutubeRecipeId, size);
} else {
return findByKeywordOrderByPostDate(keyword, lastYoutubeRecipeId, size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class RecipeSearchServiceTest extends Specification {
String keyword = "테스트"
long lastRecipeId = 0
int size = 10
String sort = "recipeScraps"
String sort = "scraps"

recipeRepository.countByKeyword(keyword) >> 2

Expand Down Expand Up @@ -118,7 +118,7 @@ class RecipeSearchServiceTest extends Specification {
String keyword = "테스트"
long lastRecipeId = 0
int size = 10
String sort = "recipeViews"
String sort = "views"

recipeRepository.countByKeyword(keyword) >> 2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BlogRecipeServiceTest extends Specification {
String keyword = "테스트"
long lastBlogRecipeId = 0
int size = 2
String sort = "blogScraps"
String sort = "scraps"

blogRecipeRepository.countByKeyword(keyword) >> 20

Expand Down Expand Up @@ -102,7 +102,7 @@ class BlogRecipeServiceTest extends Specification {
String keyword = "테스트"
long lastBlogRecipeId = 0
int size = 2
String sort = "blogViews"
String sort = "views"

blogRecipeRepository.countByKeyword(keyword) >> 20

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class YoutubeRecipeServiceTest extends Specification {
String keyword = "테스트"
long lastYoutubeRecipeId = 0
int size = 2
String sort = "youtubeScraps"
String sort = "scraps"

youtubeRecipeRepository.countByKeyword(keyword) >> 20

Expand Down Expand Up @@ -103,7 +103,7 @@ class YoutubeRecipeServiceTest extends Specification {
String keyword = "테스트"
long lastYoutubeRecipeId = 0
int size = 2
String sort = "youtubeViews"
String sort = "views"

youtubeRecipeRepository.countByKeyword(keyword) >> 20

Expand Down

0 comments on commit fe282a7

Please sign in to comment.