-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 사용자용, 관리자용 공지 전체 조회 및 공지 상세 조회 API 구현 (#312)
- Loading branch information
Showing
9 changed files
with
291 additions
and
24 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
35 changes: 35 additions & 0 deletions
35
src/main/java/com/listywave/notice/application/service/dto/NoticeFindAllResponseToAdmin.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,35 @@ | ||
package com.listywave.notice.application.service.dto; | ||
|
||
import com.listywave.notice.application.domain.Notice; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record NoticeFindAllResponseToAdmin( | ||
Long id, | ||
LocalDateTime createdDate, | ||
String title, | ||
String category, | ||
String description, | ||
boolean isExposed, | ||
boolean didSendAlarm | ||
) { | ||
|
||
public static List<NoticeFindAllResponseToAdmin> toList(List<Notice> notices) { | ||
return notices.stream() | ||
.map(NoticeFindAllResponseToAdmin::of) | ||
.toList(); | ||
} | ||
|
||
public static NoticeFindAllResponseToAdmin of(Notice notice) { | ||
return NoticeFindAllResponseToAdmin.builder() | ||
.id(notice.getId()) | ||
.createdDate(notice.getCreatedDate()) | ||
.title(notice.getTitle().getValue()) | ||
.category(notice.getType().getViewName()) | ||
.description(notice.getDescription().getValue()) | ||
.isExposed(notice.isDidSendAlarm()) | ||
.build(); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/listywave/notice/application/service/dto/NoticeFindAllResponseToUser.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,35 @@ | ||
package com.listywave.notice.application.service.dto; | ||
|
||
import com.listywave.notice.application.domain.Notice; | ||
import jakarta.annotation.Nullable; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record NoticeFindAllResponseToUser( | ||
Long id, | ||
LocalDateTime createdDate, | ||
String title, | ||
@Nullable String itemImageUrl, | ||
String category, | ||
String description | ||
) { | ||
|
||
public static List<NoticeFindAllResponseToUser> toList(List<Notice> notices) { | ||
return notices.stream() | ||
.map(NoticeFindAllResponseToUser::of) | ||
.toList(); | ||
} | ||
|
||
public static NoticeFindAllResponseToUser of(Notice notice) { | ||
return NoticeFindAllResponseToUser.builder() | ||
.id(notice.getId()) | ||
.createdDate(notice.getCreatedDate()) | ||
.title(notice.getTitle().getValue()) | ||
.itemImageUrl(notice.getFirstImageUrl()) | ||
.category(notice.getType().getViewName()) | ||
.description(notice.getDescription().getValue()) | ||
.build(); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
src/main/java/com/listywave/notice/application/service/dto/NoticeFindResponse.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,74 @@ | ||
package com.listywave.notice.application.service.dto; | ||
|
||
import com.listywave.notice.application.domain.Notice; | ||
import com.listywave.notice.application.domain.NoticeContent; | ||
import jakarta.annotation.Nullable; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record NoticeFindResponse( | ||
Long id, | ||
String category, | ||
String title, | ||
String description, | ||
List<ContentDto> contents, | ||
LocalDateTime createdDate, | ||
BesideNoticeDto prevNotice, | ||
BesideNoticeDto nextNotice | ||
) { | ||
|
||
public static NoticeFindResponse of(Notice notice, Notice prevNotice, Notice nextNotice) { | ||
return NoticeFindResponse.builder() | ||
.id(notice.getId()) | ||
.category(notice.getType().getViewName()) | ||
.title(notice.getTitle().getValue()) | ||
.description(notice.getDescription().getValue()) | ||
.contents(ContentDto.toList(notice.getContents())) | ||
.createdDate(notice.getCreatedDate()) | ||
.prevNotice(BesideNoticeDto.of(prevNotice)) | ||
.nextNotice(BesideNoticeDto.of(nextNotice)) | ||
.build(); | ||
} | ||
|
||
@Builder | ||
public record ContentDto( | ||
String type, | ||
String description, | ||
@Nullable String imageUrl, | ||
@Nullable String buttonName, | ||
@Nullable String buttonLink | ||
) { | ||
|
||
public static List<ContentDto> toList(List<NoticeContent> contents) { | ||
return contents.stream() | ||
.map(ContentDto::of) | ||
.toList(); | ||
} | ||
|
||
public static ContentDto of(NoticeContent content) { | ||
return ContentDto.builder() | ||
.type(content.getType().name().toLowerCase()) | ||
.description(content.getDescription()) | ||
.imageUrl(content.getImageUrl()) | ||
.buttonName(content.getButtonName()) | ||
.buttonLink(content.getButtonLink()) | ||
.build(); | ||
} | ||
} | ||
|
||
public record BesideNoticeDto( | ||
Long id, | ||
String title, | ||
String description | ||
) { | ||
|
||
public static BesideNoticeDto of(Notice notice) { | ||
if (notice == null) { | ||
return null; | ||
} | ||
return new BesideNoticeDto(notice.getId(), notice.getTitle().getValue(), notice.getDescription().getValue()); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.