-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feat #75 멤버 리스트 반환 수정 및 멤버 상세 조회 추가 #75
The head ref may contain hidden characters: "feat/#72/\uBA64\uBC84-\uB9AC\uC2A4\uD2B8-\uBC18\uD658-\uC218\uC815-\uBC0F-\uBA64\uBC84-\uC0C1\uC138-\uC870\uD68C-\uCD94\uAC00"
Changes from 18 commits
1bc59b2
a52ae3c
039144a
7c39040
7aaabc8
70dd74b
a185775
54aea74
e1c831e
c84d593
dd90a36
7d2eee8
95e0f35
1b453a2
0e250b7
8fe021b
d924c65
1d7ae00
ea78f3f
0022c77
80719a5
4b07c39
07017c8
4325ae8
7f755dd
96292f8
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
import leets.weeth.domain.schedule.domain.service.MeetingGetService; | ||
import leets.weeth.domain.user.application.exception.StudentIdExistsException; | ||
import leets.weeth.domain.user.application.exception.TelExistsException; | ||
import leets.weeth.domain.user.application.exception.UserNotFoundException; | ||
import leets.weeth.domain.user.application.mapper.UserMapper; | ||
import leets.weeth.domain.user.domain.entity.User; | ||
import leets.weeth.domain.user.domain.service.UserDeleteService; | ||
|
@@ -106,14 +107,33 @@ public Map<Integer, List<Response>> findAll() { | |
.collect(Collectors.groupingBy(Map.Entry::getKey, // key = 기수, value = 유저 정보 | ||
Collectors.mapping(Map.Entry::getValue, Collectors.toList()))); | ||
} | ||
|
||
@Override | ||
public Map<Integer, List<SummaryResponse>> findAllUser() { | ||
return userGetService.findAllByStatus(ACTIVE).stream() | ||
.flatMap(user -> Stream.concat( | ||
user.getCardinals().stream() | ||
.map(cardinal -> new AbstractMap.SimpleEntry<>(cardinal, mapper.toSummaryResponse(user))), // 기수별 Map | ||
Stream.of(new AbstractMap.SimpleEntry<>(0, mapper.toSummaryResponse(user))) // 모든 기수는 cardinal 0에 저장 | ||
)) | ||
.collect(Collectors.groupingBy( | ||
Map.Entry::getKey, // key = 기수 | ||
Collectors.mapping(Map.Entry::getValue, Collectors.toList()) // value = 요약 정보 리스트 | ||
)); | ||
} | ||
@Override | ||
public List<AdminResponse> findAllByAdmin() { | ||
return userGetService.findAll().stream() | ||
.map(mapper::toAdminResponse) | ||
.toList(); | ||
} | ||
|
||
@Override | ||
public Response findUserDetails(Long userId) { | ||
User user = userGetService.find(userId); | ||
if (user == null) { | ||
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.
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. 넵 해당 로직 확인하여 수정했습니다 |
||
throw new UserNotFoundException(); | ||
} | ||
return mapper.toResponse(user); | ||
} | ||
@Override | ||
public Response find(Long userId) { | ||
return mapper.to(userGetService.find(userId)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.validation.Valid; | ||
import leets.weeth.domain.user.application.dto.response.UserResponseDto.SummaryResponse; | ||
import leets.weeth.domain.user.application.usecase.UserManageUseCase; | ||
import leets.weeth.domain.user.application.usecase.UserUseCase; | ||
import leets.weeth.domain.user.domain.service.UserGetService; | ||
|
@@ -58,10 +59,17 @@ public CommonResponse<Boolean> checkEmail(@RequestParam String email) { | |
|
||
@GetMapping("/all") | ||
@Operation(summary="동아리 멤버 전체 조회(전체/기수별)") | ||
public CommonResponse<Map<Integer, List<Response>>> findAll() { | ||
return CommonResponse.createSuccess(USER_FIND_ALL_SUCCESS.getMessage(), userUseCase.findAll()); | ||
public CommonResponse<Map<Integer, List<SummaryResponse>>> findAllUser() { | ||
return CommonResponse.createSuccess(USER_FIND_ALL_SUCCESS.getMessage(), userUseCase.findAllUser()); | ||
} | ||
@GetMapping("/details") | ||
@Operation(summary = "특정 멤버 상세 조회") | ||
public CommonResponse<Response> findUser(@RequestParam Long userId) { | ||
return CommonResponse.createSuccess( | ||
USER_DETAILS_SUCCESS.getMessage(), | ||
userUseCase.findUserDetails(userId) | ||
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. 의도된 줄바꿈일까요? 길이가 길지 않아서 기존 코드 형식과 통일해도 괜찮을 것 같아요! 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. 미처 확인하지 못했던 부분입니다 |
||
); | ||
} | ||
|
||
@GetMapping | ||
@Operation(summary="내 정보 조회") | ||
public CommonResponse<Response> find(@Parameter(hidden = true) @CurrentUser Long userId) { | ||
|
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.
mapper.toSummaryResponse(user)을 반복적으로 사용하게 되는데 이부분을 한번만 호출하는건 어떨까요?
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.
해당 로직은 기존에 구현되어있던 로직과 동일한 형태로 작성했는데, 수정하지 않은 이유는 mapper.toSummaryResponse가 동일한 user 객체를 받아온다는 가정이므로 여러번 호출하더라도 성능저하가 되지 않는다고 판단했었고, 각 스트림 역할을 명확하게 읽을 수 있어 가독성이 더 좋을거같다는 생각을 했는데 어떻게 생각하시나요 ??
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.
구글링 해보니 동일한 객체를 반환하는 메서드를 반복적으로 호출하는 것만으로도 오버헤드가 발생되네요
해당 내용도 수정하겠습니다