-
Notifications
You must be signed in to change notification settings - Fork 4
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
Feature/#133-마이페이지_회원_정보_수정_기능을_제작한다 #159
The head ref may contain hidden characters: "Feature/#133-\uB9C8\uC774\uD398\uC774\uC9C0_\uD68C\uC6D0_\uC815\uBCF4_\uC218\uC815_\uAE30\uB2A5\uC744_\uC81C\uC791\uD55C\uB2E4"
Changes from all commits
bac8277
6a4405c
0e29cc5
6aa2662
d1c1c58
077c3f3
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
import static doore.team.exception.TeamExceptionType.NOT_FOUND_TEAM; | ||
|
||
import doore.login.application.dto.response.GoogleAccountProfileResponse; | ||
import doore.member.application.dto.request.MemberUpdateRequest; | ||
import doore.member.domain.Member; | ||
import doore.member.domain.StudyRole; | ||
import doore.member.domain.TeamRole; | ||
|
@@ -89,7 +90,7 @@ public void deleteMember(final Long memberId) { | |
memberRepository.delete(member); | ||
} | ||
|
||
private Member validateExistMember(final Long memberId) { | ||
public Member validateExistMember(final Long memberId) { | ||
Comment on lines
-92
to
+93
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. 테스트 때문에 public으로 바꾸신 것 같은데 저희는 각 service에서만 사용되는 메서드의 접근제어자는 private으로 설정합니다! 테스트는 테스트일 뿐인데 테스트를 위해 실제 코드의 접근을 public으로 여는 것은 위험하다고 생각해요~! |
||
return memberRepository.findById(memberId).orElseThrow(() -> new MemberException(NOT_FOUND_MEMBER)); | ||
} | ||
|
||
|
@@ -100,4 +101,10 @@ private Team validateExistTeam(final Long teamId) { | |
private Study validateExistStudy(final Long studyId) { | ||
return studyRepository.findById(studyId).orElseThrow(() -> new StudyException(NOT_FOUND_STUDY)); | ||
} | ||
|
||
public void updateMyPage(final Long memberId, final MemberUpdateRequest memberUpdateRequest) { | ||
Member member = validateExistMember(memberId); | ||
Comment on lines
+105
to
+106
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. 이 부분이 질문 주셨던 부분 같은데 이렇게 된다면 API를 요청한 사람이 본인인지는 어떻게 알까요?? |
||
member.updateName(memberUpdateRequest.newName()); | ||
memberRepository.save(member); | ||
Comment on lines
+107
to
+108
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. 굿굿! 추가로 member를 따로 저장해 줄 필요 없이 자동으로 변경감지가 된답니다~ 108번 줄은 삭제해도 될 것 같아요~! |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package doore.member.application.dto.request; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record MemberUpdateRequest( | ||
String newName | ||
Comment on lines
+6
to
+7
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. 여기서 newName은 Null이 들어오면 어떻게 될까요?? Null이 들어올 수 없도록 처리해야 할 것 같아요~ |
||
) { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
|
||
import doore.helper.IntegrationTest; | ||
import doore.login.application.dto.response.GoogleAccountProfileResponse; | ||
import doore.member.application.dto.request.MemberUpdateRequest; | ||
import doore.member.domain.Member; | ||
import doore.member.domain.StudyRole; | ||
import doore.member.domain.TeamRole; | ||
|
@@ -229,4 +230,35 @@ void init() { | |
memberCommandService.transferStudyLeader(study.getId(), member.getId(), notStudyLeaderMember.getId()); | ||
}); | ||
} | ||
|
||
@Test | ||
@DisplayName("[성공] 멤버 조회에 성공한다.") | ||
void validateExistMember_멤버_조회에_성공한다() { | ||
Member savedMember = memberCommandService.validateExistMember( | ||
member.getId() | ||
); | ||
|
||
assertThat(savedMember).isEqualTo(member); | ||
} | ||
Comment on lines
+234
to
+242
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.
|
||
|
||
@Test | ||
@DisplayName("[실패] 멤버 조회에 실패한다.") | ||
void validateExistMember_멤버_조회에_실패한다() { | ||
assertThatThrownBy(() -> memberCommandService.validateExistMember(member.getId() + 1)) | ||
.isInstanceOf(MemberException.class) | ||
.hasMessage(NOT_FOUND_MEMBER.errorMessage()); | ||
} | ||
Comment on lines
+244
to
+250
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. 추가로 코드의 가독성을 위해 잘못된 멤버 아이디는 |
||
|
||
@Test | ||
@DisplayName("[성공] 프로필 이름 수정에 성공한다.") | ||
void updateMyPage_프로필_이름_수정에_성공한다() { | ||
MemberUpdateRequest request = MemberUpdateRequest.builder() | ||
.newName("요시") | ||
.build(); | ||
|
||
memberCommandService.updateMyPage(member.getId(), request); | ||
|
||
Member findMember = memberRepository.findById(member.getId()).orElseThrow(); | ||
assertThat(findMember.getName()).isEqualTo(request.newName()); | ||
} | ||
Comment on lines
+252
to
+263
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. 👍👍 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
import doore.member.application.dto.request.MemberUpdateRequest; | ||
import doore.member.application.dto.response.MemberAndMyTeamsAndStudiesResponse; | ||
import doore.restdocs.RestDocsTest; | ||
import doore.study.application.dto.response.StudyNameResponse; | ||
|
@@ -107,4 +108,22 @@ void setUp() { | |
.andExpect(status().isOk()) | ||
.andDo(document("get-sidebar-info", pathParameters, responseFieldsSnippet)); | ||
} | ||
|
||
@Test | ||
@DisplayName("[성공] 프로필 이름 수정에 성공한다.") | ||
void updateMyPageName_프로필_이름_수정에_성공한다() throws Exception { | ||
|
||
Comment on lines
+114
to
+115
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. Nit: 개행이 없어도 될 것 같아요~ |
||
MemberUpdateRequest request = new MemberUpdateRequest("요시"); | ||
String requestJson = objectMapper.writeValueAsString(request); | ||
|
||
Comment on lines
+117
to
+118
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. 저희 |
||
doNothing().when(memberCommandService) | ||
.updateMyPage(any(Long.class), any(MemberUpdateRequest.class)); | ||
Comment on lines
+119
to
+120
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. formatter가 깨진 것 같아요~ 그리고 |
||
|
||
mockMvc.perform(RestDocumentationRequestBuilders.patch("/profile/members", 1) | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(requestJson) | ||
.header(HttpHeaders.AUTHORIZATION, accessToken)) | ||
.andExpect(status().isNoContent()) | ||
.andDo(document("update-my-page-name")); | ||
} | ||
} |
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.
윗 코멘트 참고해주세요!