Skip to content

Commit

Permalink
refactor: 동아리원 명단 조회 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
5uhwann committed Aug 22, 2023
1 parent bebe7d6 commit 522c12c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ddingdong.ddingdongBE.domain.club.controller.dto.response;

import com.fasterxml.jackson.annotation.JsonFormat;
import ddingdong.ddingdongBE.domain.club.controller.dto.request.ClubMemberDto;
import ddingdong.ddingdongBE.domain.club.entity.Club;
import ddingdong.ddingdongBE.domain.club.entity.Location;
import ddingdong.ddingdongBE.domain.club.entity.PhoneNumber;
Expand Down Expand Up @@ -46,12 +47,14 @@ public class DetailClubResponse {

private List<String> introduceImageUrls;

private List<ClubMemberDto> clubMembers;


@Builder
public DetailClubResponse(String name, String category, String tag, String content, String leader,
PhoneNumber phoneNumber, Location location, LocalDateTime startRecruitPeriod,
LocalDateTime endRecruitPeriod, String regularMeeting, String introduction,
String activity, String ideal, String formUrl,
String activity, String ideal, String formUrl, List<ClubMemberDto> clubMembers,
List<String> profileImageUrls, List<String> introduceImageUrls) {
this.name = name;
this.category = category;
Expand All @@ -69,9 +72,11 @@ public DetailClubResponse(String name, String category, String tag, String conte
this.formUrl = formUrl;
this.profileImageUrls = profileImageUrls;
this.introduceImageUrls = introduceImageUrls;
this.clubMembers = clubMembers;
}

public static DetailClubResponse of(Club club, List<String> profileImageUrls, List<String> introduceImageUrls) {
public static DetailClubResponse of(Club club, List<String> profileImageUrls, List<String> introduceImageUrls,
List<ClubMemberDto> clubMembers) {
return DetailClubResponse.builder()
.name(club.getName())
.category(club.getCategory())
Expand All @@ -88,7 +93,8 @@ public static DetailClubResponse of(Club club, List<String> profileImageUrls, Li
.ideal(club.getIdeal())
.formUrl(club.getFormUrl())
.profileImageUrls(profileImageUrls)
.introduceImageUrls(introduceImageUrls).build();
.introduceImageUrls(introduceImageUrls)
.clubMembers(clubMembers).build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static ddingdong.ddingdongBE.domain.fileinformation.entity.FileTypeCategory.IMAGE;

import ddingdong.ddingdongBE.auth.service.AuthService;
import ddingdong.ddingdongBE.domain.club.controller.dto.request.ClubMemberDto;
import ddingdong.ddingdongBE.domain.club.controller.dto.request.RegisterClubRequest;
import ddingdong.ddingdongBE.domain.club.controller.dto.request.UpdateClubRequest;
import ddingdong.ddingdongBE.domain.club.controller.dto.response.AdminClubResponse;
Expand Down Expand Up @@ -71,7 +72,11 @@ public DetailClubResponse getClub(Long clubId) {
List<String> introduceImageUrls = fileInformationService.getImageUrls(
IMAGE.getFileType() + CLUB_INTRODUCE.getFileDomain() + clubId);

return DetailClubResponse.of(club, profileImageUrl, introduceImageUrls);
List<ClubMemberDto> clubMemberDtos = club.getClubMembers().stream()
.map(ClubMemberDto::from)
.toList();

return DetailClubResponse.of(club, profileImageUrl, introduceImageUrls, clubMemberDtos);
}

@Transactional(readOnly = true)
Expand All @@ -84,7 +89,11 @@ public DetailClubResponse getMyClub(Long userId) {
List<String> introduceImageUrls = fileInformationService.getImageUrls(
IMAGE.getFileType() + CLUB_INTRODUCE.getFileDomain() + club.getId());

return DetailClubResponse.of(club, profileImageUrl, introduceImageUrls);
List<ClubMemberDto> clubMemberDtos = club.getClubMembers().stream()
.map(ClubMemberDto::from)
.toList();

return DetailClubResponse.of(club, profileImageUrl, introduceImageUrls, clubMemberDtos);
}

public void delete(Long clubId) {
Expand Down Expand Up @@ -163,4 +172,4 @@ private boolean checkRecruit(LocalDateTime now, Club club) {
}
return isRecruit;
}
}
}

0 comments on commit 522c12c

Please sign in to comment.