From 24c95ac5ab2fe066cc074e3f87026d0eb7c05209 Mon Sep 17 00:00:00 2001 From: Jihwan Jung Date: Sun, 5 May 2024 22:39:19 +0900 Subject: [PATCH] =?UTF-8?q?#32=20refactor:=20=EA=B0=80=EC=9E=85=EB=90=9C?= =?UTF-8?q?=20=EB=AA=A8=EC=9E=84=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/controller/dto/MemberResponse.java | 13 +++++++++++-- .../capstone/memberclub/dto/MemberClubResponse.java | 12 ++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 backend/src/main/java/com/project/capstone/memberclub/dto/MemberClubResponse.java diff --git a/backend/src/main/java/com/project/capstone/member/controller/dto/MemberResponse.java b/backend/src/main/java/com/project/capstone/member/controller/dto/MemberResponse.java index d1126f78c9..d8b9768eac 100644 --- a/backend/src/main/java/com/project/capstone/member/controller/dto/MemberResponse.java +++ b/backend/src/main/java/com/project/capstone/member/controller/dto/MemberResponse.java @@ -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; @@ -27,7 +28,7 @@ public record MemberResponse ( int age, Gender gender, LocalDateTime createdAt, - List clubsList, + List clubsList, List postList, List commentList, List contentList, @@ -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 createMemberClubResponseList(List memberClubList) { + List memberClubResponseList = new ArrayList<>(); + for (MemberClub memberClub : memberClubList) { + memberClubResponseList.add(new MemberClubResponse(memberClub)); + } + return memberClubResponseList; + } + private static List createSimplePostResponseList(List postList) { List simplePostResponses = new ArrayList<>(); for (Post post: postList) { diff --git a/backend/src/main/java/com/project/capstone/memberclub/dto/MemberClubResponse.java b/backend/src/main/java/com/project/capstone/memberclub/dto/MemberClubResponse.java new file mode 100644 index 0000000000..b16f30f7e1 --- /dev/null +++ b/backend/src/main/java/com/project/capstone/memberclub/dto/MemberClubResponse.java @@ -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()); + } +}