Skip to content

Commit b78c813

Browse files
Merge pull request #37 from DearObjet/feature/notification
feat: 공지사항 카테고리 확장 및 배지/New 응답 필드 추가
2 parents a680a2f + f91ec86 commit b78c813

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

src/main/java/app/dearobjet/backend/domain/notification/Notice.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ public class Notice {
2020

2121
@Enumerated(EnumType.STRING)
2222
@Column(nullable = false, length = 20)
23-
private NoticeCategory category; // NOTICE | NEWS | EVENT | FESTIVAL
23+
private NoticeCategory category; // NOTICE | NEWS | EVENT | FESTIVAL | GENERAL | GUIDE
24+
25+
@Column(length = 30)
26+
private String badge;
2427

2528
private String title;
2629

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package app.dearobjet.backend.domain.notification;
22

33
public enum NoticeCategory {
4-
NOTICE, NEWS, EVENT, FESTIVAL
4+
NOTICE, NEWS, EVENT, FESTIVAL,
5+
GENERAL, // 일반
6+
GUIDE // 이용안내
57
}

src/main/java/app/dearobjet/backend/domain/notification/NoticeResponse.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
public class NoticeResponse {
1111
private final Long noticeId;
1212
private final NoticeCategory category;
13+
private final String badge;
1314
private final String title;
1415
private final String body;
1516
private final OffsetDateTime publishedAt;
17+
private final boolean isNew;
1618
}

src/main/java/app/dearobjet/backend/domain/notification/NoticeService.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.springframework.stereotype.Service;
66
import org.springframework.transaction.annotation.Transactional;
77

8+
import java.time.OffsetDateTime;
89
import java.util.ArrayList;
910
import java.util.List;
1011

@@ -15,6 +16,8 @@ public class NoticeService {
1516

1617
private final NoticeRepository noticeRepository;
1718

19+
private static final int NEW_DAYS = 7;
20+
1821
public NoticeListResponse getNotices(NoticeCategory category, int page, int size) {
1922
Pageable pageable = PageRequest.of(
2023
Math.max(page - 1, 0), size, Sort.by(Sort.Direction.DESC, "publishedAt")
@@ -40,12 +43,16 @@ public NoticeResponse getNotice(Long noticeId) {
4043
}
4144

4245
private NoticeResponse toResponse(Notice notice) {
46+
boolean isNew = notice.getPublishedAt() != null
47+
&& notice.getPublishedAt().isAfter(OffsetDateTime.now().minusDays(NEW_DAYS));
4348
return new NoticeResponse(
4449
notice.getNotificationId(),
4550
notice.getCategory(),
51+
notice.getBadge(),
4652
notice.getTitle(),
4753
notice.getBody(),
48-
notice.getPublishedAt()
54+
notice.getPublishedAt(),
55+
isNew
4956
);
5057
}
5158
}

0 commit comments

Comments
 (0)