Skip to content

Commit

Permalink
๐Ÿ› [FIX] ๋ ˆํ๋…ธํŠธ renderType ๋ฌธ์ œ ๋‹ค์‹œ ๋กค๋ฐฑ
Browse files Browse the repository at this point in the history
  • Loading branch information
dong2ast committed Jan 18, 2024
1 parent 32a1966 commit 8702155
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package org.sopt.lequuServer.domain.book.dto.response;

import static java.util.Comparator.comparing;

import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.sopt.lequuServer.domain.book.model.Book;
import org.sopt.lequuServer.domain.note.dto.response.NoteDetailResponseDto;
Expand Down Expand Up @@ -48,14 +49,17 @@ public record BookDetailResponseDto(
public static BookDetailResponseDto of(Book book) {
String bookDate = formatLocalDate(book);

List<Note> sortedNotes = book.getNotes().stream()
.sorted(comparing(Note::getId).reversed())
.toList();

// ๋ ˆํ๋…ธํŠธ ๋ฆฌ์ŠคํŠธ ๊ฐ€๊ณต
int renderTypeCounter = 1;
List<NoteDetailResponseDto> noteList = new ArrayList<>();
for (Note note : book.getNotes()) {
for (Note note : sortedNotes) {
noteList.add(NoteDetailResponseDto.of(note, renderTypeCounter));
renderTypeCounter = (renderTypeCounter % 6 == 0) ? 1 : renderTypeCounter + 1;
}
Collections.reverse(noteList);

// ๋ถ€์ฐฉ๋œ ์Šคํ‹ฐ์ปค ๋ฆฌ์ŠคํŠธ ๊ฐ€๊ณต
List<PostedSticker> postedStickers = book.getPostedStickers();
Expand Down

0 comments on commit 8702155

Please sign in to comment.