Skip to content

Commit

Permalink
[COZY-230] feat: 카테고리 반환 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
eple0329 authored Aug 29, 2024
1 parent 6810183 commit 34b2fd0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@

public class NotificationLogConverter {

public static NotificationLogResponseDto toResponseDto(String content, LocalDateTime createdAt) {
public static NotificationLogResponseDto toResponseDto(String content, LocalDateTime createdAt,
String category) {
Duration duration = Duration.between(createdAt, LocalDateTime.now());
long minutes = duration.toMinutes();
long hours = duration.toHours();
long days = duration.toDays();
String formattedCreatedAt;

if (minutes < 60) { // 1분 ~ 59분 전
formattedCreatedAt = minutes + "분 전";
formattedCreatedAt = minutes + "분 전";
} else if (hours < 24) { // 1시간 ~ 23시간 전
formattedCreatedAt = hours + "시간 전";
} else if (days <= 3) { // 1일 ~ 3일 전
Expand All @@ -27,6 +28,7 @@ public static NotificationLogResponseDto toResponseDto(String content, LocalDate
return NotificationLogResponseDto.builder()
.content(content)
.createdAt(formattedCreatedAt)
.category(category)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public class NotificationLogResponseDto {

private String content;
private String createdAt;
private String category;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ public List<NotificationLogResponseDto> getNotificationLogList(Member member,

List<NotificationLogResponseDto> notificationLogResponseDtoList = notificationLogs.stream()
.map(notificationLog -> NotificationLogConverter.toResponseDto(
notificationLog.getContent(), notificationLog.getCreatedAt()))
notificationLog.getContent(),
notificationLog.getCreatedAt(),
notificationLog.getCategory().toString()
))
.toList();

return notificationLogResponseDtoList;
Expand Down

0 comments on commit 34b2fd0

Please sign in to comment.