Skip to content

Commit b21f338

Browse files
authored
fix: move notify_enabled select to my_rooms_query (#227)
1 parent 2a12a8f commit b21f338

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pennyway-domain/domain-rdb/src/main/java/kr/co/pennyway/domain/domains/chatroom/repository/ChatRoomCustomRepositoryImpl.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ public List<ChatRoomDetail> findChatRoomsByUserId(Long userId) {
5252
EntityPath<ChatRoom> CHAT_ROOM_ENTITY_PATH = new EntityPathBase<>(ChatRoom.class, "chat_room");
5353

5454
// 사용자가 가입한 방 필터링 서브쿼리
55-
JPQLQuery<Long> myRoomsQuery = JPAExpressions
56-
.select(Expressions.numberPath(Long.class, Chat_MEMBER_ENTITY_PATH, CHAT_ROOM_ID))
55+
JPQLQuery<Tuple> myRoomsQuery = JPAExpressions
56+
.select(
57+
Expressions.numberPath(Long.class, Chat_MEMBER_ENTITY_PATH, CHAT_ROOM_ID),
58+
Expressions.booleanPath(Chat_MEMBER_ENTITY_PATH, "notify_enabled").as(NOTIFY_ENABLED)
59+
)
5760
.from(Chat_MEMBER_ENTITY_PATH)
5861
.where(
5962
Expressions.numberPath(Long.class, Chat_MEMBER_ENTITY_PATH, "user_id").eq(userId),
@@ -68,8 +71,7 @@ public List<ChatRoomDetail> findChatRoomsByUserId(Long userId) {
6871
Expressions.booleanTemplate(
6972
"MAX(CASE WHEN user_id = {0} AND role = '0' THEN true ELSE false END)",
7073
userId
71-
).as(IS_ADMIN),
72-
Expressions.booleanPath(Chat_MEMBER_ENTITY_PATH, "notify_enabled").as(NOTIFY_ENABLED)
74+
).as(IS_ADMIN)
7375
)
7476
.from(Chat_MEMBER_ENTITY_PATH)
7577
.where(Expressions.dateTimePath(LocalDateTime.class, Chat_MEMBER_ENTITY_PATH, "deleted_at").isNull())
@@ -91,7 +93,7 @@ public List<ChatRoomDetail> findChatRoomsByUserId(Long userId) {
9193
),
9294
Expressions.booleanPath(ROOM_STATS, IS_ADMIN),
9395
Expressions.numberPath(Integer.class, ROOM_STATS, MEMBER_COUNT),
94-
Expressions.booleanPath(ROOM_STATS, NOTIFY_ENABLED)
96+
Expressions.booleanPath(MY_ROOMS, NOTIFY_ENABLED)
9597
))
9698
.from(CHAT_ROOM_ENTITY_PATH)
9799
.innerJoin(myRoomsQuery, MY_ROOMS)

0 commit comments

Comments
 (0)