Skip to content

Commit

Permalink
Merge pull request #100 from teamterning/refactor/#99
Browse files Browse the repository at this point in the history
[♻️ refactor] [2차] 홈화면 > 오늘 마감되는 관심 공고 & 캘린더(일간,월간) : 데이터 형식 및 추가 변동사항 적용
  • Loading branch information
junggyo1020 authored Aug 29, 2024
2 parents dafead4 + 660d30b commit 137ec8f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,30 @@

@Builder
public record DailyScrapResponseDto(
Long scrapId,
Long internshipAnnouncementId,
String title,
String companyImage,
String dDay,
String title,
String workingPeriod,
boolean isScrapped,
String color,
String companyImage,
int startYear,
int startMonth
String deadline,
String startYearMonth
) {
public static DailyScrapResponseDto of(final Scrap scrap){
String startYearMonth = scrap.getInternshipAnnouncement().getStartYear() + "년 " + scrap.getInternshipAnnouncement().getStartMonth() + "월";
String deadline = DateUtil.convertDeadline(scrap.getInternshipAnnouncement().getDeadline());

return DailyScrapResponseDto.builder()
.scrapId(scrap.getId())
.internshipAnnouncementId(scrap.getInternshipAnnouncement().getId())
.title(scrap.getInternshipAnnouncement().getTitle())
.companyImage(scrap.getInternshipAnnouncement().getCompany().getCompanyImage())
.dDay(DateUtil.convert(scrap.getInternshipAnnouncement().getDeadline()))
.title(scrap.getInternshipAnnouncement().getTitle())
.workingPeriod(scrap.getInternshipAnnouncement().getWorkingPeriod())
.color(scrap.getColor().getColorValue())
.companyImage(scrap.getInternshipAnnouncement().getCompany().getCompanyImage())
.startYear(scrap.getInternshipAnnouncement().getStartYear())
.startMonth(scrap.getInternshipAnnouncement().getStartMonth())
.isScrapped(true) // 스크랩된 경우에만 DTO 생성하므로 true
.color(scrap.getColorToHexValue())
.deadline(deadline)
.startYearMonth(startYearMonth)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,41 @@
@Builder
public record MonthlyListResponseDto(
String deadline,
List<ScrapDetail> scraps
List<ScrapDetail> announcements
) {
@Builder
public static record ScrapDetail(
Long scrapId,
Long internshipAnnouncementId,
String title,
String companyImage,
String dDay,
String title,
String workingPeriod,
boolean isScrapped,
String color,
String companyImage,
int startYear,
int startMonth
String deadline,
String startYearMonth
){
public static ScrapDetail of(final Long scrapId, final Long internshipAnnouncementId, final String title,
final String dDay, final String workingPeriod, final String color,
final String companyImage, final int startYear, final int startMonth){
public static ScrapDetail of(final Long internshipAnnouncementId, final String companyImage, final String dDay,
final String title, final String workingPeriod, final boolean isScrapped,
final String color, final String deadline, final String startYearMonth){
return ScrapDetail.builder()
.scrapId(scrapId)
.internshipAnnouncementId(internshipAnnouncementId)
.title(title)
.companyImage(companyImage)
.dDay(dDay)
.title(title)
.workingPeriod(workingPeriod)
.isScrapped(isScrapped)
.color(color)
.companyImage(companyImage)
.startYear(startYear)
.startMonth(startMonth)
.deadline(deadline)
.startYearMonth(startYearMonth)
.build();
}
}

public static MonthlyListResponseDto of(String deadline, List<ScrapDetail> scraps){
public static MonthlyListResponseDto of(String deadline, List<ScrapDetail> announcements){
return MonthlyListResponseDto.builder()
.deadline(deadline)
.scraps(scraps)
.announcements(announcements)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@

@Builder
public record TodayScrapResponseDto(
Long scrapId,
Long internshipAnnouncementId,
String companyImage,
String title,
String dDay,
String deadline,
String title,
String workingPeriod,
String startYearMonth,
String color
boolean isScrapped,
String color,
String deadline,
String startYearMonth
) {
public static TodayScrapResponseDto of(final Scrap scrap){
String startYearMonth = scrap.getInternshipAnnouncement().getStartYear() + "년 " + scrap.getInternshipAnnouncement().getStartMonth() + "월";

return TodayScrapResponseDto.builder()
.scrapId(scrap.getId())
.internshipAnnouncementId(scrap.getInternshipAnnouncement().getId())
.companyImage(scrap.getInternshipAnnouncement().getCompany().getCompanyImage())
.title(scrap.getInternshipAnnouncement().getTitle())
.dDay(DateUtil.convert(scrap.getInternshipAnnouncement().getDeadline()))
.title(scrap.getInternshipAnnouncement().getTitle())
.deadline(DateUtil.convertDeadline(scrap.getInternshipAnnouncement().getDeadline()))
.isScrapped(true) // 스크랩된 항목이므로 항상 true
.color(scrap.getColorToHexValue())
.workingPeriod(scrap.getInternshipAnnouncement().getWorkingPeriod())
.startYearMonth(startYearMonth)
.color(scrap.getColor().getColorValue())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,20 @@ public List<MonthlyListResponseDto> getMonthlyScrapsAsList(Long userId, int year
entry.getKey().toString(),
entry.getValue().stream()
.map(s -> MonthlyListResponseDto.ScrapDetail.of(
s.getId(),
s.getInternshipAnnouncement().getId(),
s.getInternshipAnnouncement().getTitle(),
s.getInternshipAnnouncement().getCompany().getCompanyImage(),
DateUtil.convert(s.getInternshipAnnouncement().getDeadline()),
s.getInternshipAnnouncement().getTitle(),
s.getInternshipAnnouncement().getWorkingPeriod(),
s.getColor().getColorValue(),
s.getInternshipAnnouncement().getCompany().getCompanyImage(),
s.getInternshipAnnouncement().getStartYear(),
s.getInternshipAnnouncement().getStartMonth()
true, // 이미 스크랩된 경우이므로 true
s.getColorToHexValue(),
DateUtil.convertDeadline(s.getInternshipAnnouncement().getDeadline()),
s.getInternshipAnnouncement().getStartYear() + "년 " + s.getInternshipAnnouncement().getStartMonth() + "월"
))
.toList()
))
.toList();
}

@Override
public List<DailyScrapResponseDto> getDailyScraps(Long userId, LocalDate date) {
return scrapRepository.findScrapsByUserIdAndDeadlineOrderByDeadline(userId, date).stream()
Expand Down

0 comments on commit 137ec8f

Please sign in to comment.