Skip to content

Commit

Permalink
Merge pull request #68 from Team-UniVoice/fix/#67-NO.12
Browse files Browse the repository at this point in the history
Fix/#67 no.12
  • Loading branch information
softmoca authored Jul 17, 2024
2 parents 0c6b80f + 045c49c commit d34577d
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ public class QuickQueryNoticeDTO {
private Long viewCount;
private String category;
private LocalDateTime createdAt; // 추가된 부분
private String logoImage;
private Boolean saveCheck;
}

Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,10 @@ public List<QuickQueryNoticeDTO> getQuickNoticeByUserUniversity(String affiliati
}

List<Notice> filteredNotices = notices.stream()
.filter(notice -> notice.getNoticeViews().stream()
.anyMatch(noticeView -> noticeView.getMember().getId().equals(memberId) && !noticeView.isReadAt()))
.sorted(Comparator.comparing(Notice::getCreatedAt).reversed()) // 역순 정렬
.collect(Collectors.toList());
.filter(notice -> notice.getNoticeViews().stream()
.anyMatch(noticeView -> noticeView.getMember().getId().equals(memberId) && !noticeView.isReadAt()))
.sorted(Comparator.comparing(Notice::getCreatedAt).reversed()) // 역순 정렬
.collect(Collectors.toList());

return filteredNotices.stream().map(notice -> {
String writeAffiliation = "";
Expand All @@ -314,18 +314,61 @@ public List<QuickQueryNoticeDTO> getQuickNoticeByUserUniversity(String affiliati
writeAffiliation = member.getDepartmentName() + " 학생회";
}

String logoImage = null;


Affiliation universityAffiliation = filteredNotices.stream()
.map(Notice::getMember)
.map(Member::getAffiliation)
.filter(a -> "총학생회".equals(a.getAffiliation()))
.findFirst()
.orElse(null);
if (universityAffiliation != null) {
logoImage = universityAffiliation.getAffiliationLogoImage();
}


// '단과대학학생회'에 대한 로고 이미지 가져오기
Affiliation collegeAffiliation = filteredNotices.stream()
.map(Notice::getMember)
.map(Member::getAffiliation)
.filter(a -> "단과대학 학생회".equals(a.getAffiliation()))
.findFirst()
.orElse(null);
if (collegeAffiliation != null) {
logoImage = collegeAffiliation.getAffiliationLogoImage();
}

// '과학생회'에 대한 로고 이미지 가져오기
Affiliation departmentAffiliation = filteredNotices.stream()
.map(Notice::getMember)
.map(Member::getAffiliation)
.filter(a -> "학과 학생회".equals(a.getAffiliation()))
.findFirst()
.orElse(null);
if (departmentAffiliation != null) {
logoImage = departmentAffiliation.getAffiliationLogoImage();
}


// saveCheck 로직 추가
boolean saveCheck = saveNoticeRepository.existsByMemberIdAndNoticeId(memberId, notice.getId());

return new QuickQueryNoticeDTO(
notice.getId(),
notice.getStartTime(),
notice.getEndTime(),
notice.getTitle(),
notice.getTarget(),
writeAffiliation,
notice.getContentSummary(),
notice.getNoticeLike(),
notice.getViewCount(),
notice.getCategory(),
notice.getCreatedAt()
notice.getId(),
notice.getStartTime(),
notice.getEndTime(),
notice.getTitle(),
notice.getTarget(),
writeAffiliation,
notice.getContentSummary(),
notice.getNoticeLike(),
notice.getViewCount(),
notice.getCategory(),
notice.getCreatedAt(),
logoImage,
saveCheck

);
}).collect(Collectors.toList());
}
Expand Down

0 comments on commit d34577d

Please sign in to comment.