-
Notifications
You must be signed in to change notification settings - Fork 2
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] 방 생성 및 참여 기능 구현 #64
Conversation
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 RoomJoinResponse joinRoom(@PathVariable @Positive Long roomId, @RequestBody String nickname) { | ||
return roomService.joinRoom(nickname, roomId); | ||
} |
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.
의견) 여기도 Validation 들어가야하지 않나요?
public RoomJoinResponse joinRoom(@PathVariable @Positive Long roomId, @RequestBody String nickname) { | |
return roomService.joinRoom(nickname, roomId); | |
} | |
public RoomJoinResponse joinRoom(@PathVariable @Positive Long roomId, @RequestBody @NotNull String nickname) { | |
return roomService.joinRoom(nickname, roomId); | |
} |
@Test | ||
void 존재하지_않는_방에_참여시_예외를_던진다() { | ||
// given & when | ||
String nickname = "나는참가자"; | ||
Long nonExistId = 99999999999L; | ||
MemberResponse expectedMemberResponse = new MemberResponse(5L, nickname, false); | ||
RoomJoinResponse expected = new RoomJoinResponse(nonExistId, expectedMemberResponse); | ||
|
||
// then | ||
assertThatThrownBy(() -> roomService.joinRoom(nickname, nonExistId)) | ||
.isInstanceOf(BadRequestException.class); | ||
} |
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.
의견) 사용하지 않는 변수들을 제거해 보았습니다~
@Test | |
void 존재하지_않는_방에_참여시_예외를_던진다() { | |
// given & when | |
String nickname = "나는참가자"; | |
Long nonExistId = 99999999999L; | |
MemberResponse expectedMemberResponse = new MemberResponse(5L, nickname, false); | |
RoomJoinResponse expected = new RoomJoinResponse(nonExistId, expectedMemberResponse); | |
// then | |
assertThatThrownBy(() -> roomService.joinRoom(nickname, nonExistId)) | |
.isInstanceOf(BadRequestException.class); | |
} | |
@Test | |
void 존재하지_않는_방에_참여시_예외를_던진다() { | |
// given | |
String nickname = "나는참가자"; | |
Long nonExistId = 99999999999L; | |
// when & then | |
assertThatThrownBy(() -> roomService.joinRoom(nickname, nonExistId)) | |
.isInstanceOf(BadRequestException.class); | |
} |
|
||
public RoomJoinResponse createRoom(String nickname) { | ||
Room room = roomRepository.save(new Room()); | ||
Member member = memberRepository.save(new Member(nickname, room, true)); |
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.
사소한 의견) Member에 정적 팩토리 메서드를 도입해서 createMaster(nickname, room)
, createCommon(nickname, room)
을 만드는 건 어떨까요?
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.
고생했어요 딱칸~~ 컨트롤러 테스트도 추가해주시면 감사하겠습니다 🙃
|
||
@RequestMapping("/balances/rooms") | ||
@PostMapping | ||
public RoomJoinResponse creatRoom(@RequestBody @NotNull String nickname) { |
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 RoomJoinResponse creatRoom(@RequestBody @NotNull String nickname) { | |
public RoomJoinResponse creatRoom(@Valid @RequestBody String nickname) { |
의견) 수정이 필요합니다
private final RoomService roomService; | ||
|
||
@RequestMapping("/balances/rooms") | ||
@PostMapping |
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.
@PostMapping | |
@PostMapping("/balances/rooms") |
의견) 메서드 레벨에 @RequestMapping
을 지우고 위처럼 수정하는 것은 어떨까요?
} | ||
|
||
@RequestMapping("/balances/rooms/{roomId}/members") | ||
@PostMapping |
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.
ditto
|
||
@RequestMapping("/balances/rooms/{roomId}/members") | ||
@PostMapping | ||
public RoomJoinResponse joinRoom(@PathVariable @Positive Long roomId, @RequestBody String nickname) { |
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.
@Valid
ditto
|
||
private final RoomRepository roomRepository; | ||
|
||
public RoomJoinResponse createRoom(String nickname) { |
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.
동의합니다~
return new RoomJoinResponse(room.getId(), new MemberResponse(member)); | ||
} | ||
|
||
public RoomJoinResponse joinRoom(String nickname, Long roomId) { |
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.
ditto
|
||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) |
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.
RoomService 에 createRoom 메서드에서 Room 객체를 생성해야하는데, Default 값을 통해 생성자를 생성하려면 기본생성자가 호출해야하더라고요~ 그래서 지워주었습니다!
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.
고생하셨습니다 타칸! 리뷰 확인 부탁드려요 :)
String nickname, | ||
boolean isMaster | ||
) { | ||
public MemberResponse(Member member) { |
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.
클래스는 띄어주는게 맞는데 레코드도 띄어줘야할까요?? 이 부분에 대해선 컨벤션으로 정하지 않았던 것 같아요~ 내일 다 같이 말해보죠!
@RequestMapping("/balances/rooms") | ||
@PostMapping | ||
public RoomJoinResponse creatRoom(@RequestBody @NotNull String nickname) { | ||
return roomService.createRoom(nickname); | ||
} | ||
|
||
@RequestMapping("/balances/rooms/{roomId}/members") | ||
@PostMapping | ||
public RoomJoinResponse joinRoom(@PathVariable @Positive Long roomId, @RequestBody String nickname) { |
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.
의견) PostMapping("/balances/rooms/{roomId}/members") 만 써주어도 되지 않을까요? 두 개를 다 써주신 이유가 있는 지 궁금합니다~
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.
의견) ResponseEntity로 감싸주지 않고 있는데 created, ok 등 설정하려면 필요하지 않을까 싶습니다~
아니라면 ResponseStatus 애노테이션 사용을 하는 방법도 있습니다
public Member(String nickname, Room room, boolean isMaster) { | ||
this.nickname = nickname; | ||
this.room = room; | ||
this.isMaster = isMaster; | ||
} |
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.
의견) 아까 보여주셨던 정팩메 사용해서 처리해주셔도 좋을거 같아요! createRoomMaster? 네이밍으로 말씀해주셨던 부분이요!
|
||
private final RoomRepository roomRepository; | ||
|
||
public RoomJoinResponse createRoom(String nickname) { |
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.
동의합니다~
RoomJoinResponse expected = new RoomJoinResponse(3L, expectedMemberResponse); | ||
|
||
// when | ||
RoomJoinResponse roomServiceRoom = roomService.createRoom(nickname); |
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.
사소한 의견) 커찬이 검증할 매개변수명을 actual로 스타트 끊어주셔서 이어가도 좋을 것 같아요:)
// given & when | ||
String nickname = "나는참가자"; | ||
Long nonExistId = 99999999999L; | ||
MemberResponse expectedMemberResponse = new MemberResponse(5L, nickname, false); | ||
RoomJoinResponse expected = new RoomJoinResponse(nonExistId, expectedMemberResponse); | ||
|
||
// then | ||
assertThatThrownBy(() -> roomService.joinRoom(nickname, nonExistId)) |
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.
의견) given, when&then 이 맞지 않을까요??
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.
오! 타칸 빠른 반영~~ 고생했어!! 리뷰한 내용들은 전부 문제없는 것 같아!
(Merge의 일감은 이든에게로 넘어가나요? ㅋㅋ)
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.
LGTM 🤗🤗🤗
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.
LGTM!
Issue Number
#56
As-Is
Sprint 2 P2에 맞추어 주제, 방 생성 및 참여 API 구현
To-Be
Check List
Test Screenshot
(Optional) Additional Description