-
Notifications
You must be signed in to change notification settings - Fork 2
[BE] FEAT: 메인서버 CQRS 적용 + 방 삭제/나가기 기능 추가 #260 #264
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
base: dev
Are you sure you want to change the base?
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.
Pull Request Overview
This PR introduces new CQRS functionality by separating command and query responsibilities for room operations, and implements additional endpoints for room leave and delete actions.
- Implements joinRoom, leaveRoom, and deleteRoom methods in RoomService.
- Introduces a new RoomQueryService to handle read operations.
- Updates RoomController and InvitationController to use the new service methods.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/backend/main-server/main/src/main/java/com/kickzo/main/service/RoomService.java | Refactors room join flow and adds leaveRoom and deleteRoom functionalities. |
| src/backend/main-server/main/src/main/java/com/kickzo/main/service/RoomQueryService.java | New service for handling read operations and room information retrieval. |
| src/backend/main-server/main/src/main/java/com/kickzo/main/repository/UserOutRedisRepository.java | Adds method to remove room entries from Redis. |
| src/backend/main-server/main/src/main/java/com/kickzo/main/repository/RoomUserRepository.java | Adds deleteByRoomId method for removing all room users on room deletion. |
| src/backend/main-server/main/src/main/java/com/kickzo/main/controller/RoomController.java | Updates endpoints to reflect new command/query separation and adds endpoints for leaving and deleting a room. |
| src/backend/main-server/main/src/main/java/com/kickzo/main/controller/InvitationController.java | Adjusts dependency to use RoomQueryService for invitation acceptance flow. |
Comments suppressed due to low confidence (1)
src/backend/main-server/main/src/main/java/com/kickzo/main/service/RoomService.java:90
- The call to findRoleByUserIdAndRoomId may return null; consider changing the variable type to Integer and adding a null check before comparing against 0.
int role = roomUserRepository.findRoleByUserIdAndRoomId(roomId, userId);
42inshin
left a comment
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.
java 코드도 한번씩 PR 보려고 해요~! 화이팅입니다
| int role = roomUserRepository.findRoleByUserIdAndRoomId(roomId, userId); | ||
| if (role != 0){ | ||
| throw new CustomException(CustomErrorCode.INVALID_ACCESS_ROLE); | ||
| } |
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.
role을 enum을 만들어서 관리하는건 어떨까요? 나중에 볼때 0번이 뭔지 기억 안날수도 있을 것 같아요
ai 추천으로는 아래 방식을 알려주네요 ㅎㅎ
// 삭제 권한 확인 (ADMIN = 0)
Integer role = roomUserRepository.findRoleByUserIdAndRoomId(roomId, userId);
if (role == null || !Objects.equals(role, RoomRole.ADMIN.getValue())) {
throw new CustomException(CustomErrorCode.INVALID_ACCESS_ROLE);
}public enum RoomRole {
ADMIN(0),
MEMBER(1);
private final int value;
RoomRole(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}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.
수정 완료 하였습니다! 감사합니다~
해당 사항 (중복 선택)
설명
RoomCommandService (write)
RoomQueryService (read) 의 경우
@Transactional(readOnly = true)적용🔗 관련 이슈
해결한 이슈: closed #260
📝 작업 내용
1. CQRS 패턴 적용
K6 성능 테스트 결과 (10명, 30명, 50명 들어있는 방에서 데이터 조회(GET)및 변경(POST) 성능 테스트)
2. 방 나가기 / 방 삭제 기능 추가
*creator가 방 나가기를 했을 경우 새로운 creator는 누구에게로 주어야하는가의 문제가 새롭게 생김