-
Notifications
You must be signed in to change notification settings - Fork 6
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
[BE] Feature/#399 내 정보(회원 닉네임) 수정 API 구현 #408
Changes from 13 commits
9dfea1f
afc314c
7be1f71
1613287
6d9b305
b90630c
016496f
5ffb6cb
318228f
bec7adf
fc6ba2f
31f1d06
4232fe2
190255f
8a12ba7
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
== 즐겨찾기 | ||
|
||
=== 토픽을 유저의 즐겨찾기에 추가 | ||
=== 토픽을 회원의 즐겨찾기에 추가 | ||
|
||
operation::bookmark-controller-test/add-topic-in-bookmark[snippets='http-request,http-response'] | ||
|
||
|
||
=== 유저의 토픽 즐겨찾기 삭제 | ||
=== 회원의 토픽 즐겨찾기 삭제 | ||
|
||
operation::bookmark-controller-test/delete-topic-in-bookmark[snippets='http-request,http-response'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
== 유저 | ||
== 회원 | ||
|
||
=== 유저 목록 조회 | ||
=== 회원 목록 조회 | ||
|
||
operation::member-controller-test/find-all-member[snippets='http-request,http-response'] | ||
|
||
=== 유저 단일 조회 | ||
=== 회원 단일 조회 | ||
|
||
operation::member-controller-test/find-member-by-id[snippets='http-request,http-response'] | ||
|
||
=== 유저의 나의 지도 목록 조회 | ||
=== 회원의 나의 지도 목록 조회 | ||
|
||
operation::member-controller-test/find-my-all-topics[snippets='http-request,http-response'] | ||
|
||
=== 유저의 나의 핀 목록 조회 | ||
=== 회원의 나의 핀 목록 조회 | ||
|
||
operation::member-controller-test/find-my-all-pins[snippets='http-request,http-response'] | ||
|
||
=== 유저의 모아보기 조회 | ||
=== 회원의 모아보기 조회 | ||
|
||
operation::member-controller-test/find-all-topics-in-atlas[snippets='http-request,http-response'] | ||
|
||
=== 유저의 즐겨찾기 조회 | ||
=== 회원의 즐겨찾기 조회 | ||
|
||
operation::member-controller-test/find-all-topics-in-bookmark[snippets='http-request,http-response'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.mapbefine.mapbefine.member.application; | ||
|
||
import com.mapbefine.mapbefine.auth.domain.AuthMember; | ||
import com.mapbefine.mapbefine.member.domain.Member; | ||
import com.mapbefine.mapbefine.member.domain.MemberRepository; | ||
import com.mapbefine.mapbefine.member.dto.request.MemberUpdateRequest; | ||
import com.mapbefine.mapbefine.member.exception.MemberErrorCode; | ||
import com.mapbefine.mapbefine.member.exception.MemberException.MemberConflictException; | ||
import java.util.NoSuchElementException; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@Transactional | ||
public class MemberCommandService { | ||
|
||
private final MemberRepository memberRepository; | ||
|
||
public MemberCommandService(MemberRepository memberRepository) { | ||
this.memberRepository = memberRepository; | ||
} | ||
|
||
public void updateInfoById(AuthMember authMember, MemberUpdateRequest request) { | ||
Member member = findMemberById(authMember.getMemberId()); | ||
String nickName = request.nickName(); | ||
|
||
validateNicknameDuplicated(nickName); | ||
|
||
member.update(nickName); | ||
} | ||
|
||
private Member findMemberById(Long memberId) { | ||
return memberRepository.findById(memberId) | ||
.orElseThrow(() -> new NoSuchElementException("findMemberById; memberId=" + memberId)); | ||
} | ||
|
||
private void validateNicknameDuplicated(String nickName) { | ||
if (memberRepository.existsByMemberInfoNickName(nickName)) { | ||
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 MemberConflictException(MemberErrorCode.ILLEGAL_NICKNAME_ALREADY_EXISTS, nickName); | ||
} | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,21 +98,14 @@ private static String createNickname(String nickname) { | |
private static String createNicknameSuffix() { | ||
return randomUUID() | ||
.toString() | ||
.replaceAll("-", "") | ||
.replace("-", "") | ||
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. 오 replaceAll 이랑 기능은 똑같은데 성능이 더 좋군요! 처음 알았슴둥 |
||
.substring(0, DEFAULT_NICKNAME_SUFFIX_LENGTH); | ||
} | ||
|
||
public void update( | ||
String nickName, | ||
String email, | ||
String imageUrl | ||
String nickName | ||
) { | ||
memberInfo = MemberInfo.of( | ||
nickName, | ||
email, | ||
imageUrl, | ||
memberInfo.getRole() | ||
); | ||
memberInfo = memberInfo.createUpdatedMemberInfo(nickName); | ||
} | ||
|
||
public void addTopic(Topic topic) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ public class MemberInfo { | |
@Column(nullable = false, length = 20, unique = true) | ||
private String nickName; | ||
|
||
@Column(nullable = false, unique = true) | ||
@Column(nullable = false) | ||
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. 굉장히 좋은 의견이군요! |
||
private String email; | ||
|
||
@Column(nullable = false) | ||
|
@@ -93,6 +93,11 @@ private static void validateRole(Role role) { | |
} | ||
} | ||
|
||
public MemberInfo createUpdatedMemberInfo(String nickName) { | ||
|
||
yoondgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return MemberInfo.of(nickName, this.email, this.imageUrl.getImageUrl(), this.role); | ||
} | ||
|
||
public String getImageUrl() { | ||
return imageUrl.getImageUrl(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.mapbefine.mapbefine.member.dto.request; | ||
|
||
public record MemberUpdateRequest( | ||
String nickName | ||
) { | ||
} | ||
yoondgu marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ public enum MemberErrorCode { | |
ILLEGAL_EMAIL_NULL("05002", "이메일은 필수로 입력해야합니다."), | ||
ILLEGAL_EMAIL_PATTERN("05003", "올바르지 않은 이메일 형식입니다."), | ||
MEMBER_NOT_FOUND("05400", "존재하지 않는 회원입니다."), | ||
ILLEGAL_NICKNAME_ALREADY_EXISTS("05900", "이미 존재하는 닉네임입니다."), | ||
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. 👍👍👍👍👍👍👍👍👍👍👍👍👍 |
||
; | ||
|
||
private final String code; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
INSERT INTO member (nick_name, email, image_url, role, | ||
oauth_server_id, oauth_server_type, | ||
created_at, updated_at) | ||
VALUES ('dummyMember', 'dummy@gmail.com', 'https://map-befine-official.github.io/favicon.png', 'USER', | ||
1L, 'KAKAO', | ||
now(), now()); | ||
|
||
INSERT INTO topic (name, image_url, description, | ||
permission_type, publicity, | ||
member_id, | ||
created_at, updated_at) | ||
VALUES ('dummyTopic', 'https://map-befine-official.github.io/favicon.png', 'description', | ||
'ALL_MEMBERS', 'PUBLIC', | ||
1L, | ||
now(), now()) | ||
; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.mapbefine.mapbefine.auth.infrastructure; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
@SpringBootTest(classes = JwtTokenProvider.class) | ||
@TestPropertySource(locations = "classpath:application.yml") | ||
class JwtTokenProviderTest { | ||
|
||
@Autowired | ||
private JwtTokenProvider jwtTokenProvider; | ||
|
||
@Test | ||
@DisplayName("payload를 받아 JWT 토큰을 생성한다.") | ||
void createToken() { | ||
String payload = "1"; | ||
|
||
String token = jwtTokenProvider.createToken(payload); | ||
|
||
assertThat(jwtTokenProvider.getPayload(token)) | ||
.isEqualTo(payload); | ||
} | ||
|
||
yoondgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
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.
커스텀 예외
MemberNotFoundException
구현하지 않았나요 !?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.
#405 (comment)
쥬니 pr 코드리뷰로 남긴 내용과 연결되어서 링크로 남깁니다 !
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.
저 댓글이 이 의미였군요 이해했슴돠