Skip to content

Commit

Permalink
Merge pull request #55 from kookmin-sw/BE_Feature/#32-member
Browse files Browse the repository at this point in the history
#32 refactor: 가입된 모임 리스트 응답 수정
  • Loading branch information
wjdwlghks authored May 5, 2024
2 parents 8ece3f7 + 24c95ac commit 52e3a40
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.project.capstone.member.domain.Gender;
import com.project.capstone.member.domain.Member;
import com.project.capstone.memberclub.domain.MemberClub;
import com.project.capstone.memberclub.dto.MemberClubResponse;
import com.project.capstone.mybook.domain.MyBook;
import com.project.capstone.post.controller.dto.PostResponse;
import com.project.capstone.post.controller.dto.SimplePostResponse;
Expand All @@ -27,7 +28,7 @@ public record MemberResponse (
int age,
Gender gender,
LocalDateTime createdAt,
List<MemberClub> clubsList,
List<MemberClubResponse> clubsList,
List<SimplePostResponse> postList,
List<CommentResponse> commentList,
List<ContentResponse> contentList,
Expand All @@ -36,10 +37,18 @@ public record MemberResponse (
) {
public MemberResponse(Member member) {
this(member.getId(), member.getEmail(), member.getName(), member.getAge(), member.getGender(), member.getCreatedAt(),
member.getClubs(), createSimplePostResponseList(member.getPosts()), createCommentResponseList(member.getComments()),
createMemberClubResponseList(member.getClubs()), createSimplePostResponseList(member.getPosts()), createCommentResponseList(member.getComments()),
createContentResponseList(member.getContents()), createQuizResponseList(member.getQuizzes()), createMyBookResponseList(member.getMyBooks()));
}

private static List<MemberClubResponse> createMemberClubResponseList(List<MemberClub> memberClubList) {
List<MemberClubResponse> memberClubResponseList = new ArrayList<>();
for (MemberClub memberClub : memberClubList) {
memberClubResponseList.add(new MemberClubResponse(memberClub));
}
return memberClubResponseList;
}

private static List<SimplePostResponse> createSimplePostResponseList(List<Post> postList) {
List<SimplePostResponse> simplePostResponses = new ArrayList<>();
for (Post post: postList) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.project.capstone.memberclub.dto;

import com.project.capstone.memberclub.domain.MemberClub;

public record MemberClubResponse(
Long clubId,
String name
) {
public MemberClubResponse(MemberClub memberClub) {
this(memberClub.getClub().getId(), memberClub.getClub().getName());
}
}

0 comments on commit 52e3a40

Please sign in to comment.