Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.recipe.app.src.recipe.application.blog;

import com.recipe.app.src.common.utils.BadWordFiltering;
import com.recipe.app.src.recipe.application.keyword.SearchKeywordService;
import com.recipe.app.src.common.utils.SearchKeywordNormalizer;
import com.recipe.app.src.common.utils.SearchKeywordNormalizer.SearchQuery;
import com.recipe.app.src.recipe.application.dto.RecipesResponse;
Expand All @@ -22,17 +23,20 @@ public class BlogRecipeService {
private final BlogViewService blogViewService;
private final BadWordFiltering badWordFiltering;
private final BlogRecipeClientSearchService blogRecipeClientSearchService;
private final SearchKeywordService searchKeywordService;


private static final int MIN_RECIPE_CNT = 10;

public BlogRecipeService(BlogRecipeRepository blogRecipeRepository, BlogScrapService blogScrapService, BlogViewService blogViewService,
BadWordFiltering badWordFiltering, BlogRecipeClientSearchService blogRecipeClientSearchService) {
BadWordFiltering badWordFiltering, BlogRecipeClientSearchService blogRecipeClientSearchService,
SearchKeywordService searchKeywordService) {
this.blogRecipeRepository = blogRecipeRepository;
this.blogScrapService = blogScrapService;
this.blogViewService = blogViewService;
this.badWordFiltering = badWordFiltering;
this.blogRecipeClientSearchService = blogRecipeClientSearchService;
this.searchKeywordService = searchKeywordService;
}

@Transactional
Expand All @@ -54,6 +58,9 @@ public RecipesResponse findBlogRecipesByKeyword(User user, String keyword, long
List<BlogRecipe> blogRecipes = findByKeywordOrderBy(query, lastBlogRecipeId, size, sort);
totalCnt = blogRecipeRepository.countByKeyword(query);

// 검색 로그 적재 (비동기·fire-and-forget). 욕설/빈 검색어는 위에서 이미 걸러진 상태.
searchKeywordService.record(keyword, user != null ? user.getUserId() : null);

return getRecipes(user, totalCnt, new BlogRecipes(blogRecipes));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.recipe.app.src.recipe.application.youtube;

import com.recipe.app.src.common.utils.BadWordFiltering;
import com.recipe.app.src.recipe.application.keyword.SearchKeywordService;
import com.recipe.app.src.common.utils.SearchKeywordNormalizer;
import com.recipe.app.src.common.utils.SearchKeywordNormalizer.SearchQuery;
import com.recipe.app.src.recipe.application.dto.RecipesResponse;
Expand All @@ -23,14 +24,17 @@ public class YoutubeRecipeService {
private final YoutubeViewService youtubeViewService;
private final BadWordFiltering badWordFiltering;
private final YoutubeRecipeClientSearchService youtubeRecipeClientSearchService;
private final SearchKeywordService searchKeywordService;

public YoutubeRecipeService(YoutubeRecipeRepository youtubeRecipeRepository, YoutubeScrapService youtubeScrapService, YoutubeViewService youtubeViewService,
BadWordFiltering badWordFiltering, YoutubeRecipeClientSearchService youtubeRecipeClientSearchService) {
BadWordFiltering badWordFiltering, YoutubeRecipeClientSearchService youtubeRecipeClientSearchService,
SearchKeywordService searchKeywordService) {
this.youtubeRecipeRepository = youtubeRecipeRepository;
this.youtubeScrapService = youtubeScrapService;
this.youtubeViewService = youtubeViewService;
this.badWordFiltering = badWordFiltering;
this.youtubeRecipeClientSearchService = youtubeRecipeClientSearchService;
this.searchKeywordService = searchKeywordService;
}

@Transactional
Expand All @@ -52,6 +56,9 @@ public RecipesResponse findYoutubeRecipesByKeyword(User user, String keyword, lo
List<YoutubeRecipe> youtubeRecipes = findByKeywordOrderBy(query, lastYoutubeRecipeId, size, sort);
totalCnt = youtubeRecipeRepository.countByKeyword(query);

// 검색 로그 적재 (비동기·fire-and-forget). 욕설/빈 검색어는 위에서 이미 걸러진 상태.
searchKeywordService.record(keyword, user != null ? user.getUserId() : null);

return getRecipes(user, totalCnt, new YoutubeRecipes(youtubeRecipes));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ public class BlogRecipe extends BaseEntity {
@Column(name = "blogThumbnailImgUrl")
private String blogThumbnailImgUrl;

@Column(name = "title", nullable = false, length = 128)
@Column(name = "title", nullable = false)
private String title;

@Column(name = "description", nullable = false, length = 200)
@Column(name = "description", nullable = false)
private String description;

@Column(name = "publishedAt", nullable = false)
private LocalDate publishedAt;

@Column(name = "blogName", nullable = false, length = 45)
@Column(name = "blogName", nullable = false)
private String blogName;

@Column(name = "scrapCnt", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public class YoutubeRecipe extends BaseEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long youtubeRecipeId;

@Column(name = "title", nullable = false, length = 128)
@Column(name = "title", nullable = false)
private String title;

@Column(name = "description", length = 200)
@Column(name = "description")
private String description;

@Column(name = "thumbnailImgUrl", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.recipe.app.src.recipe.application.blog

import com.recipe.app.src.common.utils.BadWordFiltering
import com.recipe.app.src.recipe.application.dto.RecipesResponse
import com.recipe.app.src.recipe.application.keyword.SearchKeywordService
import com.recipe.app.src.recipe.domain.blog.BlogRecipe
import com.recipe.app.src.recipe.domain.blog.BlogScrap
import com.recipe.app.src.recipe.infra.blog.BlogRecipeRepository
Expand All @@ -18,7 +19,8 @@ class BlogRecipeServiceTest extends Specification {
private BlogViewService blogViewService = Mock()
private BadWordFiltering badWordService = Mock()
private BlogRecipeClientSearchService blogRecipeClientSearchService = Mock()
private BlogRecipeService blogRecipeService = new BlogRecipeService(blogRecipeRepository, blogScrapService, blogViewService, badWordService, blogRecipeClientSearchService)
private SearchKeywordService searchKeywordService = Mock()
private BlogRecipeService blogRecipeService = new BlogRecipeService(blogRecipeRepository, blogScrapService, blogViewService, badWordService, blogRecipeClientSearchService, searchKeywordService)

def "블로그 레시피 검색 - 스크랩순"() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.recipe.app.src.recipe.application.youtube

import com.recipe.app.src.common.utils.BadWordFiltering
import com.recipe.app.src.recipe.application.dto.RecipesResponse
import com.recipe.app.src.recipe.application.keyword.SearchKeywordService
import com.recipe.app.src.recipe.domain.youtube.YoutubeRecipe
import com.recipe.app.src.recipe.domain.youtube.YoutubeScrap
import com.recipe.app.src.recipe.infra.youtube.YoutubeRecipeRepository
Expand All @@ -18,8 +19,9 @@ class YoutubeRecipeServiceTest extends Specification {
private YoutubeViewService youtubeViewService = Mock()
private BadWordFiltering badWordService = Mock()
private YoutubeRecipeClientSearchService youtubeRecipeClientSearchService = Mock()
private SearchKeywordService searchKeywordService = Mock()
private YoutubeRecipeService youtubeRecipeService = new YoutubeRecipeService(youtubeRecipeRepository, youtubeScrapService,
youtubeViewService, badWordService, youtubeRecipeClientSearchService)
youtubeViewService, badWordService, youtubeRecipeClientSearchService, searchKeywordService)

def "유튜브 레시피 검색 - 스크랩순"() {

Expand Down
Loading