Skip to content

Commit

Permalink
Merge pull request #73 from billbill-project/feature/borrowPosts
Browse files Browse the repository at this point in the history
[fix] 저장 검색어 주석 처리
  • Loading branch information
jainefer authored Dec 6, 2024
2 parents 1ea38fc + e634146 commit abf6f1f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,14 @@ public BaseResponse<PostsResponse.ViewAllResultResponse> getSearchPostsControlle
@Parameter(name = "sortBy", description = "정렬 기준 (예: price, createdAt, likeCount)", example = "createdAt", in = ParameterIn.QUERY, required = true)
@RequestParam(value="sortBy",required = true,defaultValue = "accuracy") String sortBy,
@Parameter(name="keyword",description = "검색 키워드(예: 6인용+텐트)",in = ParameterIn.QUERY, required = true)
@RequestParam(value = "keyword",required = true) String keyword,
@Parameter(name = "state",description = "검색어 저장 여부", in = ParameterIn.QUERY, required = true)
@RequestParam(value = "state",required = true,defaultValue = "true") boolean state) {
@RequestParam(value = "keyword",required = true) String keyword){

String userId = "";
if(MDC.get(JWTUtil.MDC_USER_ID) != null) {
userId= MDC.get(JWTUtil.MDC_USER_ID).toString();
}
Sort.Direction direction = "asc".equalsIgnoreCase(order) ? Sort.Direction.ASC : Sort.Direction.DESC;
return new BaseResponse<>(postsService.ViewSearchPostService(userId,category, page, direction, sortBy,keyword,state));
return new BaseResponse<>(postsService.ViewSearchPostService(userId,category, page, direction, sortBy,keyword,false));
}
@Operation(summary = "게시물 조회", description = "게시물 상세 조회")
@GetMapping("/{postId}")
Expand All @@ -99,15 +97,15 @@ public BaseResponse<String> deletePostController(@PathVariable(value = "postId",
}
return new BaseResponse<>(postsService.deletePostService(postId,userId));
}
@Operation(summary = "저장한 검색어 불러오기", description = "저장한 검색어 불러오기")
@GetMapping("/searchHist")
public BaseResponse<PostsResponse.saveSearchListResponse> getSearchHistController(){
String userId = "";
if(MDC.get(JWTUtil.MDC_USER_ID) != null) {
userId= MDC.get(JWTUtil.MDC_USER_ID).toString();
}
return new BaseResponse<>(postsService.findSearchService(userId));
}
// @Operation(summary = "저장한 검색어 불러오기", description = "저장한 검색어 불러오기")
// @GetMapping("/searchHist")
// public BaseResponse<PostsResponse.saveSearchListResponse> getSearchHistController(){
// String userId = "";
// if(MDC.get(JWTUtil.MDC_USER_ID) != null) {
// userId= MDC.get(JWTUtil.MDC_USER_ID).toString();
// }
// return new BaseResponse<>(postsService.findSearchService(userId));
// }

@Operation(summary = "추천 검색어 불러오기", description = "추천 검색어 주기")
@GetMapping("/recommend")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ public PostsResponse.ViewAllResultResponse ViewSearchPostService(String userId,
List<PostsResponse.Post> items = findAndConvertItems(category, pageable, keyword);
//사용자가 검색어 저장을 허용했을 경우
String tempKeyword = keyword.replaceAll("\\+", " ");
if(state){

UserSearchHistJpaEntity userSearchHist= PostsConverter.toUserSearch(user,tempKeyword);
userSearchHistRepository.save(userSearchHist);
}
// if(state){
//
// UserSearchHistJpaEntity userSearchHist= PostsConverter.toUserSearch(user,tempKeyword);
// userSearchHistRepository.save(userSearchHist);
// }
//추천 검색어를 위해 검색어 를 저장
SearchKeywordStatsJpaEntity searchKeywordStats = searchKeywordStatRepository.findByKeyword(tempKeyword);
if(searchKeywordStats!=null){
Expand Down

0 comments on commit abf6f1f

Please sign in to comment.