-
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: 신규 그룹 생성 기능 #24
Conversation
return Optional.of(new Group(name)) | ||
.map(groupRepository::save) | ||
.map(group -> new GroupResponse(group.getId(), group.getName())) | ||
.orElseThrow(() -> new ToyouException(ErrorType.INVALID_GROUP_DATA)); |
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.
혹시 map 사용하시려고 Optional.of로 감싸셨습니까!
Optional은 null-safe한 코드를 작성하기 위해 사용하는 것입니다.
A container object which may or may not contain a non-null value.
map을 Optional에서 정적 함수로 제공하는 이유도 비슷한데, null의 가능성이 있는 객체를 직접적으로 다루지 않고도 타입을 변환시킬 수 있기 때문입니다.
라이브러리를 사용할 땐 (자바 표준 라이브러리도 마찬가지) 설계자의 의도를 지키는게 중요합니다.
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.
하마터면 엔티티에 명시된 생성자로 가져온 객체인데 불필요한 로직이 들어갈 뻔 했네요 ! 역시 .. 예리하게 짚어주셔서 바로 수정했습니다.
@@ -8,13 +8,15 @@ public enum ErrorType { | |||
// 400 ~ 499 (요청 오류) | |||
RESPONSE_FORMAT_ERROR(HttpStatus.BAD_REQUEST, "TYU-400", "응답 형식 오류"), | |||
BAD_REQUEST(HttpStatus.BAD_REQUEST, "TYU-400", "잘못된 요청입니다."), | |||
INVALID_GROUP_DATA(HttpStatus.BAD_REQUEST, "TYU-4001", "Invalid group data provided"), |
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.
왜 요기만 메세지가 영어인가요?
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.
Sorry for mistake. 🧑🔬
public GroupResponse registerMember(@PathVariable long groupId) { | ||
return groupService.registerUser(groupId, 1L); // TODO: user -> argumentResolver 등록 필요 | ||
} | ||
@PostMapping("/groups/create") |
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.
엔드포인트가 저희 API 명세와 다른 것 같은데요!?!?!
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.
애초에 그룹 생성에 대한 명세가 없어서 추가하고 그룹 가입과 별개로 두었는데 빠뜨린 부분 있으면 수정하겠습니다 🙀
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.
오 이야기했던 기억은 있는 것 같은데 따로 문서화하진 않았었군요.. 알겠읍니다
다만 API 엔드포인트에 동사는 지양하도록 설계해주세요!
그룹 생성이라면 /groups
에 POST 요청을 날리는게 RESTful한 접근 방식입니다.
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.
하하 create는 애초에 errorCode를 따로 만들지 않아도 표준 에러로 명시해줄 수 있을 것 같습니다.
반영해서 수정하겠습니다 !
return Optional.of(new Group(name)) | ||
.map(groupRepository::save) | ||
.map(group -> new GroupResponse(group.getId(), group.getName())) | ||
.orElseThrow(() -> new ToyouException(ErrorType.INVALID_GROUP_DATA)); |
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.
하마터면 엔티티에 명시된 생성자로 가져온 객체인데 불필요한 로직이 들어갈 뻔 했네요 ! 역시 .. 예리하게 짚어주셔서 바로 수정했습니다.
public GroupResponse registerMember(@PathVariable long groupId) { | ||
return groupService.registerUser(groupId, 1L); // TODO: user -> argumentResolver 등록 필요 | ||
} | ||
@PostMapping("/groups/create") |
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.
애초에 그룹 생성에 대한 명세가 없어서 추가하고 그룹 가입과 별개로 두었는데 빠뜨린 부분 있으면 수정하겠습니다 🙀
@@ -8,13 +8,15 @@ public enum ErrorType { | |||
// 400 ~ 499 (요청 오류) | |||
RESPONSE_FORMAT_ERROR(HttpStatus.BAD_REQUEST, "TYU-400", "응답 형식 오류"), | |||
BAD_REQUEST(HttpStatus.BAD_REQUEST, "TYU-400", "잘못된 요청입니다."), | |||
INVALID_GROUP_DATA(HttpStatus.BAD_REQUEST, "TYU-4001", "Invalid group data provided"), |
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.
Sorry for mistake. 🧑🔬
Signed-off-by: Hyoseop Song <[email protected]>
Signed-off-by: Hyoseop Song <[email protected]>
🚀 Related Issue
close #23
📌 Tasks
📝 Details
📚 Remarks
users
,groups
등등을 단수형으로 표시하도록 수정하는 것이 명확해 보이는데 어떻게 생각하실까요 ?