Skip to content
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] 유저 조회 및 닉네임 변경 API #53

Merged
merged 5 commits into from
Jul 9, 2022

Conversation

suubinkim
Copy link
Member

이슈

작업 내용

  • 유저 정보 조회
  • 유저 닉네임 변경

기타 사항

  • controller에서 닉네임 변경에서 닉네임 하나만 받아서 requetParam 하고 거기에 바로 valid하려했는데 안 먹히더라구요 ㅠ 그래서 class에 validated 추가했는데 나중에 수정 가능하면 하겠습니다
  • 마이페이지에 url복사하기가 있어서 정보 조회시에 같이 줘야하나 하고 dto에 포함했는데 프론트쪽에서 복사를 어떤 식으로 하는지 몰라서 이게 맞나 좀 찜찜하네요
  • 닉네임 변경 api도 실제로 바뀌는지 테스트해보고 싶어서 AcceptanceTest에 추가하고 Claims 도 추가했는데 괜찮은가여..

체크리스트

  • example

@suubinkim suubinkim added 💡feature API feature 👥회원관리 회원/로그인 🔍test test labels Jul 5, 2022
@suubinkim suubinkim added this to the 4차 스프린트 milestone Jul 5, 2022
@suubinkim suubinkim self-assigned this Jul 5, 2022
@suubinkim suubinkim added this to To do in BeTree via automation Jul 5, 2022
…1-BE into feature/user-info

� Conflicts:
�	src/test/java/com/yapp/betree/controller/AcceptanceTest.java
Copy link
Contributor

@kang-jisu kang-jisu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

테스트도 꼼꼼하게 넘 잘해주신거같습니다!! 💯💯
몇가지 남긴부분 한번 확인부탁드릴게요!!

controller에서 닉네임 변경에서 닉네임 하나만 받아서 requetParam 하고 거기에 바로 valid하려했는데 안 먹히더라구요 ㅠ 그래서 class에 validated 추가했는데 나중에 수정 가능하면 하겠습니다

원래 @Valid가 클래스단위로만 동작하는거라 String, Long에는 안먹어서 지금처럼 구현하신게 맞는방법일거예요!

마이페이지에 url복사하기가 있어서 정보 조회시에 같이 줘야하나 하고 dto에 포함했는데 프론트쪽에서 복사를 어떤 식으로 하는지 몰라서 이게 맞나 좀 찜찜하네요

DTO에 포함해서 보내는거 전 좋아보입니다!!

닉네임 변경 api도 실제로 바뀌는지 테스트해보고 싶어서 AcceptanceTest에 추가하고 Claims 도 추가했는데 괜찮은가여..
혹시 테스트 성공하시나요? ㅠㅠ

 @Test
    @DisplayName("유저 닉네임 변경 테스트")
    void updateUserNickname() throws Exception {
        User user = UserTest.TEST_USER;
        userRepository.save(user);

        String token = JwtTokenTest.JWT_TOKEN_TEST;
        given(jwtTokenProvider.parseToken(token)).willReturn(claims(user.getId()));

jwtTokenProvider를 mock처리하게되는데 AcceptanceTest에 다른 테스트들은 @Autowired로 받아온 jwtTokenProvider를 써야 제대로 동작할거라 제생각에는 닉네임변경테스트용+jwtTokenProvider를 @MockBean으로 설정하는 테스트클래스 따로 분리하는게 좋을 것 같아요! MessageAcceptanceTest 처럼요 !!

@ApiResponses({
@ApiResponse(code = 404, message = "[U005]회원을 찾을 수 없습니다.")
})
@GetMapping("/api/user")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기본적으로 다른 api들이 복수형을 쓰고있어서 /api/users/info 이런식이여도 좋을 것 같아요!
그냥 /api/users만 하자니 전체리스트를 가져오는거 같기도 해서 info 같은거도 추가하는방식으로 ..!!
어떠실까요!

@ApiResponses({
@ApiResponse(code = 404, message = "[U005]회원을 찾을 수 없습니다.")
})
@PatchMapping("/api/user")
Copy link
Contributor

@kang-jisu kang-jisu Jul 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위에 남긴거랑 비슷하게 이것도 /api/users/nickname정도로 좀 더 상세하게 url을 변경해도 좋을 것 같고,

저는 개인적으로 HTTP Method를 GET POST (PUT, DELETE)정도만 사용하는것도 나쁘지는 않아보여요! 프론트백엔드끼리 약속만 되어있다면 엄청 세세하게 규칙을 지키는 것 보다는 덜 헷갈리고 통일성있게 하는게 더 낫다는 의견입니다!!
닉네임만 변경한다고 Patch로 바꾸기엔 다른 변경 메서드들은 다 PUT으로 되어있기도 해서요 !(메시지 boolean값 변경에 대한 것들도..!)

+)
아니면 기존 put이었던것들도 의미에 맞게 바꿀만한거있으면 patch로 바꾸고 쓰는게 좋을거같아요!

그냥 제 개인적인 의견이니깐 한번 생각해봐주세욥 !

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 하면서 이것만 patch라 맞나 싶긴했는데 통일하는게 맞는것 같아요 그럼 기존것들은 나두고 이걸 변경할게요..!

this.userImage = userImage;
}

public static UserResponseDto of(User user) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☺️👍

.andExpect(jsonPath("$").value(TEST_SAVE_USER.getId()));
}

@DisplayName("유저 닉네임 변경 - 공백일때 예외처리")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

.andExpect(jsonPath("$.errors.[*].message").value("닉네임은 빈값일 수 없습니다."));
}

@DisplayName("유저 닉네임 변경 - 글자수 20자 초과시 예외처리")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

…1-BE into feature/user-info

� Conflicts:
�	src/test/java/com/yapp/betree/controller/AcceptanceTest.java
@suubinkim suubinkim merged commit 8821974 into YAPP-Github:develop Jul 9, 2022
BeTree automation moved this from To do to Done Jul 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👥회원관리 회원/로그인 💡feature API feature 🔍test test
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants