-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: BestSellerRepository Zset으로 자료구조 변경 (#115)
- Loading branch information
Showing
14 changed files
with
222 additions
and
148 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
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
16 changes: 12 additions & 4 deletions
16
src/main/java/com/jisungin/application/book/event/BestSellerUpdatedEvent.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,16 +1,24 @@ | ||
package com.jisungin.application.book.event; | ||
|
||
import com.jisungin.infra.crawler.CrawlingBook; | ||
import com.jisungin.application.book.request.BookCreateServiceRequest; | ||
import com.jisungin.infra.crawler.CrawledBook; | ||
import java.util.List; | ||
import java.util.Map; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class BestSellerUpdatedEvent { | ||
|
||
private final Map<Long, CrawlingBook> crawledBooks; | ||
private final Map<Long, CrawledBook> crawledBookMap; | ||
|
||
public BestSellerUpdatedEvent(Map<Long, CrawlingBook> crawledBooks) { | ||
this.crawledBooks = crawledBooks; | ||
public BestSellerUpdatedEvent(Map<Long, CrawledBook> crawledBookMap) { | ||
this.crawledBookMap = crawledBookMap; | ||
} | ||
|
||
public List<BookCreateServiceRequest> getServiceRequests() { | ||
return crawledBookMap.values().stream() | ||
.map(CrawledBook::toServiceRequest) | ||
.toList(); | ||
} | ||
|
||
} |
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
1 change: 0 additions & 1 deletion
1
src/main/java/com/jisungin/application/book/request/BookCreateServiceRequest.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
38 changes: 38 additions & 0 deletions
38
src/main/java/com/jisungin/application/book/request/BookCreateServiceRequests.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,38 @@ | ||
package com.jisungin.application.book.request; | ||
|
||
import com.jisungin.domain.book.Book; | ||
import java.util.List; | ||
import java.util.Set; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class BookCreateServiceRequests { | ||
|
||
private final List<BookCreateServiceRequest> requests; | ||
|
||
@Builder | ||
private BookCreateServiceRequests(List<BookCreateServiceRequest> requests) { | ||
this.requests = requests; | ||
} | ||
|
||
public static BookCreateServiceRequests of(List<BookCreateServiceRequest> requests) { | ||
return BookCreateServiceRequests.builder() | ||
.requests(requests) | ||
.build(); | ||
} | ||
|
||
public List<String> getIsbns() { | ||
return requests.stream() | ||
.map(BookCreateServiceRequest::getIsbn) | ||
.toList(); | ||
} | ||
|
||
public List<Book> toEntitiesNotInclude(Set<String> existIsbns) { | ||
return requests.stream() | ||
.filter(request -> !existIsbns.contains(request.getIsbn())) | ||
.map(BookCreateServiceRequest::toEntity) | ||
.toList(); | ||
} | ||
|
||
} |
45 changes: 0 additions & 45 deletions
45
src/main/java/com/jisungin/application/book/response/BestSellerResponse.java
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
src/main/java/com/jisungin/application/book/response/BookWithRankingResponse.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,58 @@ | ||
package com.jisungin.application.book.response; | ||
|
||
import com.jisungin.infra.crawler.CrawledBook; | ||
import java.time.LocalDateTime; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class BookWithRankingResponse { | ||
|
||
private Long ranking; | ||
private String isbn; | ||
private String title; | ||
private String publisher; | ||
private String thumbnail; | ||
private String[] authors; | ||
private LocalDateTime dateTime; | ||
|
||
@Builder | ||
private BookWithRankingResponse(Long ranking, String isbn, String title, String publisher, String thumbnail, | ||
String[] authors, LocalDateTime dateTime) { | ||
this.ranking = ranking; | ||
this.isbn = isbn; | ||
this.title = title; | ||
this.publisher = publisher; | ||
this.thumbnail = thumbnail; | ||
this.authors = authors; | ||
this.dateTime = dateTime; | ||
} | ||
|
||
public static BookWithRankingResponse of(Long ranking, String isbn, String title, String publisher, String thumbnail, | ||
String[] authors, LocalDateTime dateTime) { | ||
return BookWithRankingResponse.builder() | ||
.ranking(ranking) | ||
.isbn(isbn) | ||
.title(title) | ||
.publisher(publisher) | ||
.thumbnail(thumbnail) | ||
.authors(authors) | ||
.dateTime(dateTime) | ||
.build(); | ||
} | ||
|
||
public static BookWithRankingResponse ofRankIncrement(Long ranking, CrawledBook crawledBook) { | ||
return BookWithRankingResponse.builder() | ||
.ranking(ranking + 1) | ||
.isbn(crawledBook.getIsbn()) | ||
.title(crawledBook.getTitle()) | ||
.publisher(crawledBook.getPublisher()) | ||
.thumbnail(crawledBook.getThumbnail()) | ||
.authors(crawledBook.getAuthors()) | ||
.dateTime(crawledBook.getDateTime()) | ||
.build(); | ||
} | ||
|
||
} |
Oops, something went wrong.