33
44import com .project .smunionbe .domain .club .dto .response .ClubResDTO ;
55import com .project .smunionbe .domain .club .dto .response .DepartmentResDTO ;
6+ import com .project .smunionbe .domain .club .dto .response .GalleryResDTO ;
67import com .project .smunionbe .domain .club .entity .Club ;
78import com .project .smunionbe .domain .club .exception .ClubErrorCode ;
89import com .project .smunionbe .domain .club .exception .ClubException ;
10+ import com .project .smunionbe .domain .club .repository .ClubRepository ;
11+ import com .project .smunionbe .domain .club .repository .GalleryRepository ;
912import com .project .smunionbe .domain .member .entity .MemberClub ;
13+ import com .project .smunionbe .domain .member .exception .MemberClubErrorCode ;
14+ import com .project .smunionbe .domain .member .exception .MemberClubException ;
1015import com .project .smunionbe .domain .member .repository .MemberClubRepository ;
16+ import com .project .smunionbe .domain .notification .attendance .dto .response .AttendanceResDTO ;
17+ import com .project .smunionbe .domain .notification .attendance .repository .AttendanceRepository ;
18+ import com .project .smunionbe .domain .notification .fee .dto .response .FeeResDTO ;
19+ import com .project .smunionbe .domain .notification .fee .repository .FeeNoticeRepository ;
20+ import com .project .smunionbe .domain .notification .vote .dto .response .VoteResDTO ;
21+ import com .project .smunionbe .domain .notification .vote .repository .VoteNoticeRepository ;
1122import lombok .RequiredArgsConstructor ;
1223import lombok .extern .slf4j .Slf4j ;
1324import org .springframework .stereotype .Service ;
1425import org .springframework .transaction .annotation .Transactional ;
1526
27+ import java .time .LocalDateTime ;
1628import java .util .List ;
1729
1830@ Service
2133@ Transactional (readOnly = true )
2234public class ClubQueryService {
2335 private final MemberClubRepository memberClubRepository ;
36+ private final ClubRepository clubRepository ;
37+ private final AttendanceRepository attendanceRepository ;
38+ private final FeeNoticeRepository feeNoticeRepository ;
39+ private final VoteNoticeRepository voteNoticeRepository ;
40+ private final GalleryRepository galleryRepository ;
41+
2442 public ClubResDTO .GetMemberClubListResDTO getAllMemberClubList (
2543 Long memberClubId
2644 ) {
@@ -42,4 +60,82 @@ public ClubResDTO.GetMemberClubListResDTO getAllMemberClubList(
4260
4361 return new ClubResDTO .GetMemberClubListResDTO (memberClubResponseList );
4462 }
63+
64+ public ClubResDTO .ClubDetailResDTO getclubDetailResDTO (
65+ Long memberClubId
66+ ) {
67+ MemberClub memberClub = memberClubRepository .findById (memberClubId )
68+ .orElseThrow (() -> new MemberClubException (MemberClubErrorCode .INVALID_MEMBER_CLUB ));
69+ Club club = clubRepository .findById (memberClub .getClub ().getId ())
70+ .orElseThrow (() -> new ClubException (ClubErrorCode .CLUB_NOT_FOUND ));
71+
72+ Long clubId = club .getId ();
73+
74+
75+ List <AttendanceResDTO .AttendanceDetailResponse > attendanceDetailResponses = attendanceRepository .findAllByClubId (clubId )
76+ .stream ()
77+ .map (attendanceNotice -> new AttendanceResDTO .AttendanceDetailResponse (
78+ attendanceNotice .getId (),
79+ attendanceNotice .getTitle (),
80+ attendanceNotice .getContent (),
81+ attendanceNotice .getTarget (),
82+ attendanceNotice .getDate (),
83+ attendanceNotice .getCreatedAt ()
84+ ))
85+ .toList ();
86+
87+ List <FeeResDTO .FeeNoticeResponse > feeNoticeResponseList = feeNoticeRepository .findAllByClubId (clubId )
88+ .stream ()
89+ .map (feeNotice -> new FeeResDTO .FeeNoticeResponse (
90+ feeNotice .getId (),
91+ feeNotice .getTitle (),
92+ feeNotice .getContent (),
93+ feeNotice .getTarget (),
94+ feeNotice .getAmount (),
95+ feeNotice .getBank (),
96+ feeNotice .getAccountNumber (),
97+ feeNotice .getParticipantCount (),
98+ feeNotice .getDate (),
99+ feeNotice .getCreatedAt ()
100+
101+ ))
102+ .toList ();
103+
104+ List <VoteResDTO .VoteResponse > voteResponses = voteNoticeRepository .findAllByClubId (clubId )
105+ .stream ()
106+ .map (voteNotice -> new VoteResDTO .VoteResponse (
107+ voteNotice .getId (),
108+ voteNotice .getTitle (),
109+ voteNotice .getContent (),
110+ voteNotice .getTarget (),
111+ voteNotice .getDate (),
112+ voteNotice .isAllowDuplicate (),
113+ voteNotice .isAnonymous (),
114+ voteNotice .getCreatedAt ()
115+ ))
116+ .toList ();
117+
118+ List <GalleryResDTO .GetGalleryResDTO > galleryResDTOS = galleryRepository .findAllByClubId (memberClub .getClub ().getId ())
119+ .stream ()
120+ .map (gallery -> new GalleryResDTO .GetGalleryResDTO (
121+ gallery .getId (),
122+ gallery .getName (),
123+ gallery .getThumbnailUrl ()
124+ ))
125+ .toList ();
126+
127+ return new ClubResDTO .ClubDetailResDTO (
128+ club .getName (),
129+ club .getDescription (),
130+ club .getThumbnailUrl (),
131+ attendanceDetailResponses ,
132+ feeNoticeResponseList ,
133+ voteResponses ,
134+ galleryResDTOS
135+ );
136+ }
137+
138+
139+
140+
45141}
0 commit comments