-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 관련도 정렬을 제외한 리스트 검색 기능 구현 (#99)
- Loading branch information
Showing
6 changed files
with
197 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.listywave.common.util; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
public class StringUtils { | ||
|
||
public static boolean match(String source, String keyword) { | ||
return source.matches(".*" + Pattern.quote(keyword) + ".*"); | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
src/main/java/com/listywave/list/application/domain/SortType.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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.listywave.list.application.domain; | ||
|
||
public enum SortType { | ||
|
||
NEW, | ||
OLD, | ||
RELATED, | ||
COLLECTED, | ||
; | ||
} |
79 changes: 79 additions & 0 deletions
79
src/main/java/com/listywave/list/application/dto/response/ListSearchResponse.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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.listywave.list.application.dto.response; | ||
|
||
import com.listywave.list.application.domain.Item; | ||
import com.listywave.list.application.domain.Lists; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record ListSearchResponse( | ||
List<ListInfo> resultLists, | ||
Long totalCount, | ||
Long cursorId, | ||
boolean hasNext | ||
) { | ||
|
||
public static ListSearchResponse of(java.util.List<Lists> lists, Long totalCount, Long cursorId, boolean hasNext) { | ||
return ListSearchResponse.builder() | ||
.resultLists(ListInfo.toList(lists)) | ||
.totalCount(totalCount) | ||
.cursorId(cursorId) | ||
.hasNext(hasNext) | ||
.build(); | ||
} | ||
} | ||
|
||
@Builder | ||
record ListInfo( | ||
Long id, | ||
String title, | ||
java.util.List<ItemInfo> items, | ||
boolean isPublic, | ||
String backgroundColor, | ||
LocalDateTime updatedDate, | ||
Long ownerId, | ||
String ownerNickname, | ||
String ownerProfileImageUrl | ||
) { | ||
|
||
public static List<ListInfo> toList(java.util.List<Lists> lists) { | ||
return lists.stream() | ||
.map(ListInfo::of) | ||
.toList(); | ||
} | ||
|
||
private static ListInfo of(Lists lists) { | ||
return ListInfo.builder() | ||
.id(lists.getId()) | ||
.title(lists.getTitle()) | ||
.items(ItemInfo.toList(lists.getItems())) | ||
.isPublic(lists.isPublic()) | ||
.backgroundColor(lists.getBackgroundColor()) | ||
.updatedDate(lists.getUpdatedDate()) | ||
.ownerId(lists.getUser().getId()) | ||
.ownerNickname(lists.getUser().getNickname()) | ||
.ownerProfileImageUrl(lists.getUser().getProfileImageUrl()) | ||
.build(); | ||
} | ||
} | ||
|
||
@Builder | ||
record ItemInfo( | ||
Long id, | ||
String title | ||
) { | ||
|
||
public static java.util.List<ItemInfo> toList(java.util.List<Item> items) { | ||
return items.stream() | ||
.map(ItemInfo::of) | ||
.toList(); | ||
} | ||
|
||
private static ItemInfo of(Item item) { | ||
return ItemInfo.builder() | ||
.id(item.getId()) | ||
.title(item.getTitle()) | ||
.build(); | ||
} | ||
} |
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