-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DDING-66] ClubMember 목록 조회 API 응답값 변경 #201
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package ddingdong.ddingdongBE.domain.club.controller.dto.response; | ||
|
||
import ddingdong.ddingdongBE.domain.clubmember.entity.ClubMember; | ||
import ddingdong.ddingdongBE.domain.clubmember.service.dto.query.AllClubMemberInfoQuery; | ||
import io.swagger.v3.oas.annotations.media.ArraySchema; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import java.util.List; | ||
|
||
public record AllClubMemberInfoResponse( | ||
@Schema(name = "동아리명", example = "COW") | ||
String clubName, | ||
@ArraySchema(schema = @Schema(implementation = ClubMemberListResponse.class)) | ||
List<ClubMemberListResponse> clubMembers | ||
) { | ||
|
||
public static AllClubMemberInfoResponse from(AllClubMemberInfoQuery query) { | ||
List<ClubMemberListResponse> responses = query.clubMembers().stream() | ||
.map(ClubMemberListResponse::from) | ||
.toList(); | ||
return new AllClubMemberInfoResponse(query.clubName(), responses); | ||
} | ||
|
||
@Schema( | ||
name = "ClubMemberResponse", | ||
description = "중앙동아리 - 동아리원 조회 응답" | ||
) | ||
record ClubMemberListResponse( | ||
@Schema(description = "식별자", example = "1") | ||
Long id, | ||
@Schema(description = "이름", example = "홍길동") | ||
String name, | ||
@Schema(description = "학번", example = "60001111") | ||
String studentNumber, | ||
@Schema(description = "전화번호", example = "010-1234-5678") | ||
String phoneNumber, | ||
@Schema(description = "동아리원 역할", | ||
example = "LEADER", | ||
allowableValues = {"LEADER", "EXECUTION", "MEMBER"} | ||
) | ||
String position, | ||
@Schema(description = "학과", example = "학과") | ||
String department | ||
) { | ||
|
||
public static ClubMemberListResponse from(ClubMember clubMember) { | ||
return new ClubMemberListResponse( | ||
clubMember.getId(), | ||
clubMember.getName(), | ||
clubMember.getStudentNumber(), | ||
clubMember.getPhoneNumber(), | ||
clubMember.getPosition().getName(), | ||
clubMember.getDepartment() | ||
); | ||
} | ||
Comment on lines
+45
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion from 메서드에서 position 매핑 로직 개선이 필요합니다.
- clubMember.getPosition().getName(),
+ clubMember.getPosition(),
|
||
|
||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package ddingdong.ddingdongBE.domain.clubmember.service.dto.query; | ||
|
||
import ddingdong.ddingdongBE.domain.clubmember.entity.ClubMember; | ||
import java.util.List; | ||
|
||
public record AllClubMemberInfoQuery( | ||
String clubName, | ||
List<ClubMember> clubMembers | ||
) { | ||
|
||
public static AllClubMemberInfoQuery of(String clubName, List<ClubMember> clubMembers) { | ||
return new AllClubMemberInfoQuery(clubName, clubMembers); | ||
} | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Position 필드를 enum으로 변경하는 것이 좋겠습니다.
현재
position
필드가 String으로 되어있는데, 허용 가능한 값이 제한적이므로 enum을 사용하는 것이 타입 안전성을 보장할 수 있습니다.그리고 다음과 같이 변경하세요: