Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#8]♻️Refacotr: dateTime localdate로 변경 #54

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import univ.yesummit.domain.comment.api.dto.response.CommentInfoResDto;
import univ.yesummit.domain.member.entity.Member;

import java.time.format.DateTimeFormatter;
import java.util.List;

@Builder
Expand All @@ -24,14 +25,19 @@ public record BoardInfoResDto(
int InvestmentCount,
boolean invest,
int commentCount,
String date,
String date, // 포맷팅된 날짜 필드
List<CommentInfoResDto> comments
) {
public static BoardInfoResDto of(Member member, Board board, boolean isLike) {
// 이미지 URL 변환
List<String> imageUrl = board.getPictures().stream()
.map(BoardPicture::getImageUrl)
.toList();

// 날짜 포맷 설정
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String formattedDate = board.getBoardDate().format(formatter);

return BoardInfoResDto.builder()
.myMemberId(member.getId())
.writerMemberId(board.getWriter().getId())
Expand All @@ -43,8 +49,51 @@ public static BoardInfoResDto of(Member member, Board board, boolean isLike) {
.serviceUrl(builder().serviceUrl)
.PTUrl(builder().PTUrl)
.likeCount(board.getLikeCount())
.isLike(isLike)
.commentCount(board.getComments().size())
.date(board.getBoardDate())
.date(formattedDate) // 포맷팅된 날짜 전달
.build();
}
}

//
//@Builder
//public record BoardInfoResDto(
// Long myMemberId,
// Long writerMemberId,
// String writerMemberName,
// Long boardId,
// String title,
// String content,
// List<String> imageUrl,
// String serviceUrl,
// String PTUrl,
// int likeCount,
// boolean isLike,
// int InvestmentCount,
// boolean invest,
// int commentCount,
// String date,
// List<CommentInfoResDto> comments
//) {
// public static BoardInfoResDto of(Member member, Board board, boolean isLike) {
// List<String> imageUrl = board.getPictures().stream()
// .map(BoardPicture::getImageUrl)
// .toList();
//
// return BoardInfoResDto.builder()
// .myMemberId(member.getId())
// .writerMemberId(board.getWriter().getId())
// .writerMemberName(board.getWriter().getUsername())
// .boardId(board.getBoardId())
// .title(board.getTitle())
// .content(board.getContent())
// .imageUrl(imageUrl)
// .serviceUrl(builder().serviceUrl)
// .PTUrl(builder().PTUrl)
// .likeCount(board.getLikeCount())
// .commentCount(board.getComments().size())
// .date(board.getBoardDate())
// .build();
// }
//}
4 changes: 2 additions & 2 deletions src/main/java/univ/yesummit/domain/board/domain/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class Board {
private Long summitId;

@Schema(description = "게시글 날짜", example = "2024.06.21")
private String boardDate;
private LocalDateTime boardDate;

@Schema(description = "좋아요 개수", example = "1")
private int likeCount;
Expand All @@ -76,7 +76,7 @@ private Board(String title, String content, String serviceUrl, String PTUrl, Mem
this.pictures = pictures;
this.serviceUrl = serviceUrl;
this.PTUrl = PTUrl;
this.boardDate = String.valueOf(LocalDateTime.now(ZoneId.of("Asia/Seoul")));
this.boardDate = LocalDateTime.now(ZoneId.of("Asia/Seoul"));
this.likeCount = 0;
this.writer = writer;
this.summitId = summitId;
Expand Down
Loading