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] 방 생성 및 참여 기능 구현 #64

Merged
merged 7 commits into from
Jul 25, 2024
Merged

[FEAT] 방 생성 및 참여 기능 구현 #64

merged 7 commits into from
Jul 25, 2024

Conversation

jhon3242
Copy link
Member

@jhon3242 jhon3242 commented Jul 24, 2024

Issue Number

#56

As-Is

Sprint 2 P2에 맞추어 주제, 방 생성 및 참여 API 구현

To-Be

  • 방 생성 API 추가
  • 방 참여 API 추가

Check List

  • [�X] 테스트가 전부 통과되었나요?
  • 모든 commit이 push 되었나요?
  • merge할 branch를 확인했나요?
  • Assignee를 지정했나요?
  • Label을 지정했나요?

Test Screenshot

image

(Optional) Additional Description

@jhon3242 jhon3242 added ✨ feat 기능 추가 🍃 BE back end labels Jul 24, 2024
@jhon3242 jhon3242 added this to the BE Sprint2 milestone Jul 24, 2024
@jhon3242 jhon3242 self-assigned this Jul 24, 2024
Copy link
Contributor

@leegwichan leegwichan left a comment

Choose a reason for hiding this comment

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

타콩! 빠르게 구현하느라 고생 많았어!
일단 내 눈에 보이는 부분 위주로 봤어 한 번 확인해 줘!

Comment on lines 31 to 33
public RoomJoinResponse joinRoom(@PathVariable @Positive Long roomId, @RequestBody String nickname) {
return roomService.joinRoom(nickname, roomId);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

의견) 여기도 Validation 들어가야하지 않나요?

Suggested change
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);
}

Comment on lines 55 to 66
@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);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

의견) 사용하지 않는 변수들을 제거해 보았습니다~

Suggested change
@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));
Copy link
Contributor

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)을 만드는 건 어떨까요?

Copy link
Member Author

Choose a reason for hiding this comment

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

그게 의미가 더 잘 전달 될 것 같네요! 바로 반영해볼게요~

Copy link
Member

@GIVEN53 GIVEN53 left a 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) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public RoomJoinResponse creatRoom(@RequestBody @NotNull String nickname) {
public RoomJoinResponse creatRoom(@Valid @RequestBody String nickname) {

의견) 수정이 필요합니다

private final RoomService roomService;

@RequestMapping("/balances/rooms")
@PostMapping
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@PostMapping
@PostMapping("/balances/rooms")

의견) 메서드 레벨에 @RequestMapping을 지우고 위처럼 수정하는 것은 어떨까요?

}

@RequestMapping("/balances/rooms/{roomId}/members")
@PostMapping
Copy link
Member

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) {
Copy link
Member

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) {
Copy link
Member

Choose a reason for hiding this comment

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

의견) 트랜잭션이 필요할 것 같습니당

Copy link
Member

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) {
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

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

질문) 제거된 이유가 있나요??

Copy link
Member Author

Choose a reason for hiding this comment

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

RoomService 에 createRoom 메서드에서 Room 객체를 생성해야하는데, Default 값을 통해 생성자를 생성하려면 기본생성자가 호출해야하더라고요~ 그래서 지워주었습니다!

Copy link
Member

@PgmJun PgmJun left a 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) {
Copy link
Member

Choose a reason for hiding this comment

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

사소한 의견) 한칸 띄워야하지 않나용?

Copy link
Member Author

@jhon3242 jhon3242 Jul 24, 2024

Choose a reason for hiding this comment

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

클래스는 띄어주는게 맞는데 레코드도 띄어줘야할까요?? 이 부분에 대해선 컨벤션으로 정하지 않았던 것 같아요~ 내일 다 같이 말해보죠!

Comment on lines 23 to 31
@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) {
Copy link
Member

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") 만 써주어도 되지 않을까요? 두 개를 다 써주신 이유가 있는 지 궁금합니다~

Copy link
Member

Choose a reason for hiding this comment

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

의견) ResponseEntity로 감싸주지 않고 있는데 created, ok 등 설정하려면 필요하지 않을까 싶습니다~
아니라면 ResponseStatus 애노테이션 사용을 하는 방법도 있습니다

Comment on lines 34 to 38
public Member(String nickname, Room room, boolean isMaster) {
this.nickname = nickname;
this.room = room;
this.isMaster = isMaster;
}
Copy link
Member

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) {
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

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

사소한 의견) 커찬이 검증할 매개변수명을 actual로 스타트 끊어주셔서 이어가도 좋을 것 같아요:)

Comment on lines 57 to 64
// 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))
Copy link
Member

Choose a reason for hiding this comment

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

의견) given, when&then 이 맞지 않을까요??

Copy link
Member Author

@jhon3242 jhon3242 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
Contributor

@leegwichan leegwichan left a comment

Choose a reason for hiding this comment

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

오! 타칸 빠른 반영~~ 고생했어!! 리뷰한 내용들은 전부 문제없는 것 같아!
(Merge의 일감은 이든에게로 넘어가나요? ㅋㅋ)

Copy link
Member

@GIVEN53 GIVEN53 left a comment

Choose a reason for hiding this comment

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

LGTM 🤗🤗🤗

Copy link
Member

@PgmJun PgmJun left a comment

Choose a reason for hiding this comment

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

LGTM!

@jhon3242 jhon3242 merged commit 3f756de into develop Jul 25, 2024
1 check passed
@GIVEN53 GIVEN53 deleted the feat/#56 branch December 10, 2024 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍃 BE back end ✨ feat 기능 추가
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants