Skip to content

Commit

Permalink
[DDING-66] ClubMember 목록 조회 API 응답값 변경 (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
KoSeonJe authored Jan 8, 2025
1 parent 33c9d4d commit 0704a01
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
import ddingdong.ddingdongBE.common.exception.ErrorResponse;
import ddingdong.ddingdongBE.domain.club.controller.dto.request.UpdateClubInfoRequest;
import ddingdong.ddingdongBE.domain.club.controller.dto.request.UpdateClubMemberRequest;
import ddingdong.ddingdongBE.domain.club.controller.dto.response.CentralClubMemberListResponse;
import ddingdong.ddingdongBE.domain.club.controller.dto.response.AllClubMemberInfoResponse;
import ddingdong.ddingdongBE.domain.club.controller.dto.response.MyClubInfoResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
Expand All @@ -16,7 +15,6 @@
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -54,10 +52,10 @@ public interface CentralClubApi {
@Operation(summary = "동아리원 명단 조회 API")
@ResponseStatus(HttpStatus.OK)
@ApiResponse(responseCode = "200", description = "동아리원 명단 조회 성공",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = CentralClubMemberListResponse.class))))
content = @Content(schema = @Schema(implementation = AllClubMemberInfoResponse.class)))
@SecurityRequirement(name = "AccessToken")
@GetMapping("/club-members")
List<CentralClubMemberListResponse> getMyClubMembers(@AuthenticationPrincipal PrincipalDetails principalDetails);
AllClubMemberInfoResponse getMyClubMembers(@AuthenticationPrincipal PrincipalDetails principalDetails);

@Operation(summary = "내 동아리 정보 수정 API")
@ResponseStatus(HttpStatus.NO_CONTENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import ddingdong.ddingdongBE.domain.club.api.CentralClubApi;
import ddingdong.ddingdongBE.domain.club.controller.dto.request.UpdateClubInfoRequest;
import ddingdong.ddingdongBE.domain.club.controller.dto.request.UpdateClubMemberRequest;
import ddingdong.ddingdongBE.domain.club.controller.dto.response.CentralClubMemberListResponse;
import ddingdong.ddingdongBE.domain.club.controller.dto.response.AllClubMemberInfoResponse;
import ddingdong.ddingdongBE.domain.club.controller.dto.response.MyClubInfoResponse;
import ddingdong.ddingdongBE.domain.club.service.FacadeCentralClubService;
import ddingdong.ddingdongBE.domain.club.service.dto.query.MyClubInfoQuery;
import ddingdong.ddingdongBE.domain.clubmember.service.FacadeCentralClubMemberService;
import ddingdong.ddingdongBE.domain.clubmember.service.dto.command.UpdateClubMemberListCommand;
import ddingdong.ddingdongBE.domain.clubmember.service.dto.query.AllClubMemberInfoQuery;
import ddingdong.ddingdongBE.domain.user.entity.User;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
Expand Down Expand Up @@ -54,11 +54,10 @@ public MyClubInfoResponse getMyClub(PrincipalDetails principalDetails) {
}

@Override
public List<CentralClubMemberListResponse> getMyClubMembers(PrincipalDetails principalDetails) {
public AllClubMemberInfoResponse getMyClubMembers(PrincipalDetails principalDetails) {
User user = principalDetails.getUser();
return facadeCentralClubMemberService.getAllMyClubMember(user.getId()).stream()
.map(CentralClubMemberListResponse::from)
.toList();
AllClubMemberInfoQuery query = facadeCentralClubMemberService.getAllMyClubMember(user.getId());
return AllClubMemberInfoResponse.from(query);
}

@Override
Expand Down
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()
);
}

}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

import ddingdong.ddingdongBE.domain.clubmember.service.dto.command.UpdateClubMemberCommand;
import ddingdong.ddingdongBE.domain.clubmember.service.dto.command.UpdateClubMemberListCommand;
import ddingdong.ddingdongBE.domain.clubmember.service.dto.query.CentralClubMemberListQuery;
import java.util.List;
import ddingdong.ddingdongBE.domain.clubmember.service.dto.query.AllClubMemberInfoQuery;

public interface FacadeCentralClubMemberService {

byte[] getClubMemberListFile(Long userId);

List<CentralClubMemberListQuery> getAllMyClubMember(Long userId);
AllClubMemberInfoQuery getAllMyClubMember(Long userId);

void updateMemberList(UpdateClubMemberListCommand command);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import ddingdong.ddingdongBE.domain.clubmember.entity.ClubMember;
import ddingdong.ddingdongBE.domain.clubmember.service.dto.command.UpdateClubMemberCommand;
import ddingdong.ddingdongBE.domain.clubmember.service.dto.command.UpdateClubMemberListCommand;
import ddingdong.ddingdongBE.domain.clubmember.service.dto.query.CentralClubMemberListQuery;
import ddingdong.ddingdongBE.domain.clubmember.service.dto.query.AllClubMemberInfoQuery;
import ddingdong.ddingdongBE.file.service.ExcelFileService;
import java.util.HashSet;
import java.util.List;
Expand All @@ -31,11 +31,9 @@ public byte[] getClubMemberListFile(Long userId) {
}

@Override
public List<CentralClubMemberListQuery> getAllMyClubMember(Long userId) {
public AllClubMemberInfoQuery getAllMyClubMember(Long userId) {
Club club = clubService.getByUserId(userId);
return club.getClubMembers().stream()
.map(CentralClubMemberListQuery::from)
.toList();
return AllClubMemberInfoQuery.of(club.getName(), club.getClubMembers());
}

@Override
Expand Down
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.

0 comments on commit 0704a01

Please sign in to comment.