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

[POM-94] feat: 가게 전화번호 등록 기능 구현 #31

Merged
merged 8 commits into from
Sep 14, 2023

Conversation

juno-junho
Copy link
Collaborator

📌 설명

  • 가게 전화번호 등록 기능 구현
  • 컨트롤러 200 ok
  • Store 불변 엔티티로 전화번호 변경시 새로운 엔티티 객체 생성
  • 메서드마다 테스트 작성

Comment on lines 37 to 38
@PostMapping("/{id}/phone-numbers")
public void registerPhoneNumber(@RequestBody @Valid PhoneNumberRequest phoneNumberRequest, @PathVariable(value = "id") Long storeId) {
Copy link
Member

Choose a reason for hiding this comment

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

전화번호 하나 추가하는 것이면 patchMapping은 어떤가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

수정하는것도 있어서 이것은 추후 수정할 생각이에요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

patchmapping은 동일한 메서드로 하나 추가할 생각입니다

Copy link
Member

@Juhongseok Juhongseok left a comment

Choose a reason for hiding this comment

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

👍

Co-authored-by: HongSeok Ju <[email protected]>
Copy link
Collaborator

@hyeon-z hyeon-z left a comment

Choose a reason for hiding this comment

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

👍

import java.util.regex.Pattern;

@Embeddable
@EqualsAndHashCode(of = "tel")
Copy link
Collaborator

Choose a reason for hiding this comment

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

컬럼이 tel만 존재하는 때 of로 따로 지정해준 이유가 있을까요?

return requiredStoreInfo.getBusinessNumber();
}

public Store afterRegisterPhoneNumber(String phoneNumber) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

registerPhoneNumber앞에 after를 붙여준 이유가 있나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

store.afterRegisterPhoneNumber()가 자연스럽다고 생각했어요
메서드 명 정할때 중요한 점이 사용하는 클라이언트 쪽에서 메서드 명을 정해야지 받는쪽 입장에서 메서드 명을 정하는 것은 객체지향적이지 못하다고 생각해요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

반환값이 store 엔티티이기 때문에 after 붙히는게 더 자연스럽다 생각합니다 :)

.isThrownBy(() -> storeService.registerPhoneNumber(validPhoneNumber, store.getId()));
}


Copy link
Collaborator

Choose a reason for hiding this comment

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

엔터 2개 들어가있습니다!

Copy link
Collaborator

@ddongpuri ddongpuri left a comment

Choose a reason for hiding this comment

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

⚓︎

Copy link
Collaborator

@choi5798 choi5798 left a comment

Choose a reason for hiding this comment

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

궁금한 점 코멘트 남겼습니다

return requiredStoreInfo.getBusinessNumber();
}

public Store afterRegisterPhoneNumber(String phoneNumber) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

메소드명만 보고는 폰 번호 등록 이후에 어떤 기능을 수행하는지 잘 모르겠어요

Comment on lines +74 to +75
public String getTel() {
return tel.getTel();
Copy link
Collaborator

Choose a reason for hiding this comment

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

필드 tel 의 타입과 해당 필드의 getter 타입이 달라요

Comment on lines +39 to +43
public void registerPhoneNumber(String phoneNumber, Long storeId) {
Store store = findStore(storeId).afterRegisterPhoneNumber(phoneNumber);
storeRepository.save(store);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

repostiroy.save() 메소드의 return 값을 뭔가 유용하게 이용할 수 있을 것 같아요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

지금 컨트롤러에 굳이 넘겨 줘야할 필요가 없어서 (자원이 생성된게 아니기 때문에) return 값을 설정하지 않았어요

@DisplayName("전화번호가 정상적으로 등록된다")
void successRegisterPhoneNumber() {
// given
String validPhoneNumber = "010-1234-5678";
Copy link
Collaborator

Choose a reason for hiding this comment

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

StoreTest 와 이 test 파일간의 유효한 폰 번호 문자열의 포맷이 달라요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

상관없다고 생각해요 어차피 유효한 번호인것만 테스트 하면 되니까요

@juno-junho juno-junho merged commit f280919 into dev Sep 14, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants