Skip to content

Commit 6b97317

Browse files
namgigunloseminho
andauthored
Hotfix/loseminho : terminated 상태 조회 제거
* refactor: 스더티룸 권한에 대한 로직 개선 * fix: ci에서 통과 못한 테스트코드 수정 * fix:rest api와 웹소켓 중간 경로 통합 * fix:rest api와 웹소켓 중간 경로 통합 * fix: 에러 확인을 위한 통합테스트 추가, Room.create()메서드 수정 * refactor, feat : 조회 분할 * refactor: redis 로직 최적화 및 중복 검증 로직 제거 * fix: 에러 번호 수정 * feat: 스터디룸 방 비밀번호 변경 및 삭제 기능 구현 * fix:app-dev 제거 * feat: 웹소켓 기반 소극적 하트비트 * feat: 스터디룸 썸네일 기능 추가 및 webrtc 설정 변경에서 주석처리 * fix:소극적 하트비트 사용 주석처리 * Feat: 스터디 룸 내에 고양이 아바타 시스템과 프로필 이미지 url 연동 * fix: 기존 작성되어있던 test 코드 수정 * test: 아바타 테스트 코드 완료 * refactor: 프론트엔드 요청 사항에 따른 스터디룸 조회 마스킹 제거 * feat: 스터디룸 방 초대 코드 시스템 * Infra: main branch 로컬 환경과 운영 환경 동기화 * Infra: docker-compose 파일 수정 - Redis 버전 업그레이드 기존: 6.2 -> 변경: 7.0 * Fix: 백엔드 CD 파일 수정 - 자동화 시, 잘못된 도메인으로 호스트 ID 검증하는 오류 해결 * Infra: EC2 환경변수 수정 - 잘못 표기한 도메인 네임 변경 * Chore: CD 파일 수정 - Github Actions commandLine 인식 문제로 인해 set -Eeuo pipefail 줄바꿈 * Chore: 백엔드 CD 파일 수정 - 인스턴스 ID 체크 삭제 * Infra: 백엔드 CD 파일 수정 - .env 파일 추가시, $DOT_ENV_PROD -> $DOT_ENV 로 변경 * Infra: 도커 컴포즈 수정 - mysql 사용자 정보 변경 * Infra: 운영환경 설정 - application-prod.yml 과 application.yml 동기화 * Fix: SecurityConfig 수정 - H2 DB 허용 X * test,fix: 방 초대에 대한 테스트 코드 작성 및 에러 수정 * fix: 스터디룸 파일 업로드 맵핑 형식으로 변환 * fix: 병합충돌 제어 수정 * fix: 병합충돌 제어 * fix: 스터디 룸 내 프론트엔드 요구 사항 및 오류사항 수정 * feat: 방 즐겨찾기, 방 공지사항 구현 * fix: mockbean 수정 * fix: 테스트에서 빠진 비로그인 사용자 추가 * hotfix: 누락된 사용자 추방에 대한 컨트롤러 추가 * hotfix: VISITOR도 추방 가능하도록 수정 * fix: 누락된 테스트코드 추가 및 테스트코드 로직 수정 * refactor: 아바타 시스템 db와 분리 및 테스트 코드 수정 * fix: 턴서버 dev에 맞춤 * hotfix: 추방 후 추방당한 유저에게 개인 메시지 전송 로직 추가 * fix: 웹소켓 메세지 전송 * fix: 병합 오류 제어 * test: 테스트코드 수정 * refactor: 스터디룸 파일 업로드 s3 + fileAttachment + Mapping 제거 방식으로 수정 * feat: 방 내 방명록 기능 추가 * hotfix:로젝 내 웹소켓 세션 제거 * hotfix: 방 조회 시 terminated 상태는 조회 안되도록 --------- Co-authored-by: loseminho <[email protected]>
1 parent 6cd3aba commit 6b97317

File tree

1 file changed

+40
-21
lines changed

1 file changed

+40
-21
lines changed

src/main/java/com/back/domain/studyroom/repository/RoomRepositoryImpl.java

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ public class RoomRepositoryImpl implements RoomRepositoryCustom {
3333
private final QUser user = QUser.user;
3434

3535
/**
36-
* 공개 방 중 입장 가능한 방들 조회 (페이징)
36+
* 공개 방 중 입장 가능한 방들 조회 (페이징, TERMINATED 제외)
3737
* 조회 조건:
3838
* - 비공개가 아닌 방 (isPrivate = false)
3939
* - 활성화된 방 (isActive = true)
4040
* - 입장 가능한 상태 (WAITING 또는 ACTIVE)
41-
*
41+
*
4242
* 참고: 정원 체크는 Redis 기반으로 프론트엔드/서비스에서 수행
4343
* @param pageable 페이징 정보
4444
* @return 페이징된 방 목록
@@ -52,7 +52,8 @@ public Page<Room> findJoinablePublicRooms(Pageable pageable) {
5252
.where(
5353
room.isPrivate.eq(false),
5454
room.isActive.eq(true),
55-
room.status.in(RoomStatus.WAITING, RoomStatus.ACTIVE)
55+
room.status.in(RoomStatus.WAITING, RoomStatus.ACTIVE), // WAITING, ACTIVE만 (TERMINATED, PAUSED 제외)
56+
room.status.ne(RoomStatus.TERMINATED) // TERMINATED 명시적 제외
5657
)
5758
.orderBy(room.createdAt.desc())
5859
.offset(pageable.getOffset())
@@ -66,15 +67,16 @@ public Page<Room> findJoinablePublicRooms(Pageable pageable) {
6667
.where(
6768
room.isPrivate.eq(false),
6869
room.isActive.eq(true),
69-
room.status.in(RoomStatus.WAITING, RoomStatus.ACTIVE)
70+
room.status.in(RoomStatus.WAITING, RoomStatus.ACTIVE),
71+
room.status.ne(RoomStatus.TERMINATED)
7072
)
7173
.fetchOne();
7274

7375
return new PageImpl<>(rooms, pageable, totalCount != null ? totalCount : 0);
7476
}
7577

7678
/**
77-
* 사용자가 참여 중인 방 조회 (MEMBER 이상만)
79+
* 사용자가 참여 중인 방 조회 (MEMBER 이상만, TERMINATED 제외)
7880
* 조회 조건:
7981
* - 특정 사용자가 MEMBER 이상으로 등록된 방 (VISITOR 제외)
8082
* - DB에 저장된 멤버십만 조회
@@ -89,7 +91,8 @@ public List<Room> findRoomsByUserId(Long userId) {
8991
.join(room.roomMembers, roomMember) // 멤버 조인
9092
.where(
9193
roomMember.user.id.eq(userId),
92-
roomMember.role.ne(com.back.domain.studyroom.entity.RoomRole.VISITOR) // VISITOR 제외
94+
roomMember.role.ne(com.back.domain.studyroom.entity.RoomRole.VISITOR), // VISITOR 제외
95+
room.status.ne(RoomStatus.TERMINATED) // TERMINATED 제외
9396
)
9497
.fetch();
9598
}
@@ -160,7 +163,7 @@ public Page<Room> findRoomsWithFilters(String title, RoomStatus status, Boolean
160163
}
161164

162165
/**
163-
* 인기 방 조회 (참가자 수 기준) - 공개+비공개 포함
166+
* 인기 방 조회 (참가자 수 기준, TERMINATED 제외)
164167
*
165168
* 참고: 참가자 수는 Redis에서 조회하므로 DB에서는 정렬 불가
166169
* 서비스 레이어에서 Redis 데이터로 정렬 필요
@@ -177,7 +180,8 @@ public Page<Room> findPopularRooms(Pageable pageable) {
177180
.selectFrom(room)
178181
.leftJoin(room.createdBy, user).fetchJoin() // N+1 방지
179182
.where(
180-
room.isActive.eq(true)
183+
room.isActive.eq(true),
184+
room.status.ne(RoomStatus.TERMINATED) // TERMINATED 제외
181185
)
182186
.orderBy(room.createdAt.desc()) // 최신순 (서비스에서 Redis 기반으로 재정렬)
183187
.offset(pageable.getOffset())
@@ -189,7 +193,8 @@ public Page<Room> findPopularRooms(Pageable pageable) {
189193
.select(room.count())
190194
.from(room)
191195
.where(
192-
room.isActive.eq(true)
196+
room.isActive.eq(true),
197+
room.status.ne(RoomStatus.TERMINATED) // TERMINATED 제외
193198
)
194199
.fetchOne();
195200

@@ -272,23 +277,26 @@ public Optional<Room> findByIdWithLock(Long roomId) {
272277
}
273278

274279
/**
275-
* 모든 방 조회 (공개 + 비공개 전체)
280+
* 모든 방 조회 (공개 + 비공개 전체, TERMINATED 제외)
276281
* 조회 조건:
277282
* - 모든 방 (공개 + 비공개)
278283
* 정렬:
279284
* 1. 열린 방(WAITING, ACTIVE) 우선
280285
* 2. 닫힌 방(PAUSED, TERMINATED) 뒤로
281286
* 3. 최신 생성순
282-
*
287+
*
283288
* 비공개 방은 컨트롤러/서비스 레이어에서 정보 마스킹 합니당
284289
*/
285290
@Override
286291
public Page<Room> findAllRooms(Pageable pageable) {
287292
List<Room> rooms = queryFactory
288293
.selectFrom(room)
289294
.leftJoin(room.createdBy, user).fetchJoin()
295+
.where(
296+
room.status.ne(RoomStatus.TERMINATED) // TERMINATED 제외
297+
)
290298
.orderBy(
291-
// 열린 방 우선 (0), 닫힌 방 뒤로 (1)
299+
// 열린 방 우선 (0), 일시정지 방 뒤로 (1)
292300
room.status.when(RoomStatus.WAITING).then(0)
293301
.when(RoomStatus.ACTIVE).then(0)
294302
.otherwise(1).asc(),
@@ -302,23 +310,27 @@ public Page<Room> findAllRooms(Pageable pageable) {
302310
Long totalCount = queryFactory
303311
.select(room.count())
304312
.from(room)
313+
.where(
314+
room.status.ne(RoomStatus.TERMINATED) // TERMINATED 제외
315+
)
305316
.fetchOne();
306317

307318
return new PageImpl<>(rooms, pageable, totalCount != null ? totalCount : 0);
308319
}
309320

310321
/**
311-
* 공개 방 전체 조회
322+
* 공개 방 전체 조회 (TERMINATED 제외)
312323
* 조회 조건:
313324
* - isPrivate = false
314325
* - includeInactive에 따라 닫힌 방 포함 여부 결정
315326
* 정렬: 열린 방 우선 → 최신순
316327
*/
317328
@Override
318329
public Page<Room> findPublicRoomsWithStatus(boolean includeInactive, Pageable pageable) {
319-
BooleanExpression whereClause = room.isPrivate.eq(false);
330+
BooleanExpression whereClause = room.isPrivate.eq(false)
331+
.and(room.status.ne(RoomStatus.TERMINATED)); // TERMINATED 제외
320332

321-
// 닫힌 방 제외 옵션
333+
// 일시정지 방 제외 옵션
322334
if (!includeInactive) {
323335
whereClause = whereClause.and(
324336
room.status.in(RoomStatus.WAITING, RoomStatus.ACTIVE)
@@ -349,7 +361,7 @@ public Page<Room> findPublicRoomsWithStatus(boolean includeInactive, Pageable pa
349361
}
350362

351363
/**
352-
* 내가 멤버인 비공개 방 조회
364+
* 내가 멤버인 비공개 방 조회 (TERMINATED 제외)
353365
* 조회 조건:
354366
* - isPrivate = true
355367
* - 내가 멤버로 등록된 방
@@ -359,9 +371,10 @@ public Page<Room> findPublicRoomsWithStatus(boolean includeInactive, Pageable pa
359371
@Override
360372
public Page<Room> findMyPrivateRooms(Long userId, boolean includeInactive, Pageable pageable) {
361373
BooleanExpression whereClause = room.isPrivate.eq(true)
362-
.and(roomMember.user.id.eq(userId));
374+
.and(roomMember.user.id.eq(userId))
375+
.and(room.status.ne(RoomStatus.TERMINATED)); // TERMINATED 제외
363376

364-
// 닫힌 방 제외 옵션
377+
// 일시정지 방 제외 옵션
365378
if (!includeInactive) {
366379
whereClause = whereClause.and(
367380
room.status.in(RoomStatus.WAITING, RoomStatus.ACTIVE)
@@ -394,7 +407,7 @@ public Page<Room> findMyPrivateRooms(Long userId, boolean includeInactive, Pagea
394407
}
395408

396409
/**
397-
* 내가 호스트(방장)인 방 조회
410+
* 내가 호스트(방장)인 방 조회 (TERMINATED 제외)
398411
* 조회 조건:
399412
* - room.createdBy.id = userId
400413
* 정렬: 열린 방 우선 → 최신순
@@ -404,7 +417,10 @@ public Page<Room> findRoomsByHostId(Long userId, Pageable pageable) {
404417
List<Room> rooms = queryFactory
405418
.selectFrom(room)
406419
.leftJoin(room.createdBy, user).fetchJoin()
407-
.where(room.createdBy.id.eq(userId))
420+
.where(
421+
room.createdBy.id.eq(userId),
422+
room.status.ne(RoomStatus.TERMINATED) // TERMINATED 제외
423+
)
408424
.orderBy(
409425
room.status.when(RoomStatus.WAITING).then(0)
410426
.when(RoomStatus.ACTIVE).then(0)
@@ -418,7 +434,10 @@ public Page<Room> findRoomsByHostId(Long userId, Pageable pageable) {
418434
Long totalCount = queryFactory
419435
.select(room.count())
420436
.from(room)
421-
.where(room.createdBy.id.eq(userId))
437+
.where(
438+
room.createdBy.id.eq(userId),
439+
room.status.ne(RoomStatus.TERMINATED) // TERMINATED 제외
440+
)
422441
.fetchOne();
423442

424443
return new PageImpl<>(rooms, pageable, totalCount != null ? totalCount : 0);

0 commit comments

Comments
 (0)