-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
75 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
server/src/main/java/dev/findfirst/core/model/SearchBkmkByTagReq.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
package dev.findfirst.core.model; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import java.util.Arrays; | ||
|
||
import jakarta.validation.constraints.NotEmpty; | ||
|
||
public record SearchBkmkByTagReq(@NotEmpty String[]tags){@Override public boolean equals(Object obj){if(obj instanceof SearchBkmkByTagReq tagSearch){return Arrays.equals(this.tags(),tagSearch.tags());}return false;} | ||
|
||
@Override public int hashCode(){return Arrays.hashCode(this.tags());} | ||
|
||
@Override public String toString(){return Arrays.toString(this.tags());} | ||
|
||
public record SearchBkmkByTagReq(@NotBlank String tag) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 10 additions & 14 deletions
24
server/src/main/java/dev/findfirst/core/service/SearchService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,40 @@ | ||
package dev.findfirst.core.service; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.StringJoiner; | ||
|
||
import dev.findfirst.core.dto.BookmarkOnly; | ||
import dev.findfirst.core.dto.TagDTO; | ||
import dev.findfirst.core.model.jdbc.TagJDBC; | ||
import dev.findfirst.core.repository.jdbc.BookmarkJDBCRepository; | ||
import dev.findfirst.core.repository.jdbc.TagJDBCRepository; | ||
import dev.findfirst.security.userauth.context.UserContext; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class SearchService { | ||
|
||
private final TagJDBCRepository tagRepository; | ||
|
||
private final BookmarkJDBCRepository bookmarkRepo; | ||
|
||
private final BookmarkService bookmarkService; | ||
|
||
private final UserContext userContext; | ||
|
||
public List<BookmarkOnly> titleKeywordSearch(String[] keywords) { | ||
public List<BookmarkOnly> titleKeyword(String[] keywords) { | ||
StringJoiner joiner = new StringJoiner(" | "); | ||
for (String kw : keywords) { | ||
joiner.add(kw); | ||
} | ||
return bookmarkService | ||
.convertBookmarkJDBCToBookmarkOnly(bookmarkRepo.titleKeywordSearch(joiner.toString(), userContext.getUserId())); | ||
return bookmarkService.convertBookmarkJDBCToBookmarkOnly( | ||
bookmarkRepo.titleKeywordSearch(joiner.toString(), userContext.getUserId())); | ||
} | ||
|
||
public List<BookmarkOnly> bookmarkSearchByTagTitles(List<String> titles) { | ||
List<TagJDBC> foundTags = tagRepository.findByTagTitles(titles, userContext.getUserId()); | ||
List<BookmarkOnly> foundBookmarks = new ArrayList<>(); | ||
return foundBookmarks; | ||
public List<BookmarkOnly> bookmarksByTags(String[] tags) { | ||
return bookmarkService.convertBookmarkJDBCToBookmarkOnly( | ||
bookmarkRepo.findBookmarkByTagTitle(Arrays.asList(tags), userContext.getUserId())); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters