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

Bug/#187 chatroom 조회 오류 수정 #188

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,32 @@
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

@Schema(description = "채팅방 리스트 조회 응답")
@Getter
@AllArgsConstructor
public class ChatRoomPublicRes {
@Schema(description = "프로젝트 ID")
private Long projectId;
@Schema(description = "채팅방 ID")
private String chatRoomId;
@Setter
@Schema(description = "마지막 메시지")
private String lastMessage;
@Setter
@Schema(description = "마지막 메시지 생성 시간")
private LocalDateTime lastMessageCreatedAt;
@Schema(description = "채팅방 상태")
private ChatStatus status;

private List<ChatUserInfo> profiles;

public ChatRoomPublicRes(Long projectId, String chatRoomId, ChatStatus status,
List<ChatUserInfo> profiles) {
this.projectId = projectId;
this.chatRoomId = chatRoomId;
this.status = status;
this.profiles = profiles;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.oeid.mogakgo.domain.chat.infrastructure;

import static io.oeid.mogakgo.domain.chat.entity.document.QChatRoom.chatRoom;
import static io.oeid.mogakgo.domain.user.domain.QUser.user;

import com.querydsl.core.types.Projections;
import com.querydsl.jpa.impl.JPAQueryFactory;
import io.oeid.mogakgo.domain.chat.application.dto.res.ChatRoomPublicRes;
import io.oeid.mogakgo.domain.chat.application.vo.ChatUserInfo;
import io.oeid.mogakgo.domain.user.domain.QUser;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
Expand All @@ -18,13 +18,15 @@ public class ChatRoomCustomRepositoryImpl implements ChatRoomCustomRepository {
private final JPAQueryFactory jpaQueryFactory;

public List<ChatRoomPublicRes> findAllChatRoomByUserId(Long userId) {

QUser sender = new QUser("sender");
QUser creator = new QUser("creator");

return jpaQueryFactory.select(
Projections.constructor(
ChatRoomPublicRes.class,
chatRoom.project.id,
chatRoom.id,
null,
null,
chatRoom.status,
Projections.list(List.of(
Projections.constructor(
Expand All @@ -42,7 +44,7 @@ public List<ChatRoomPublicRes> findAllChatRoomByUserId(Long userId) {
)
)
)
).from(chatRoom).join(chatRoom.creator, user).join(chatRoom.sender, user)
).from(chatRoom).join(chatRoom.creator, creator).join(chatRoom.sender, sender)
.where(chatRoom.creator.id.eq(userId).or(chatRoom.sender.id.eq(userId)))
.fetch();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public UserProfileResponse getUserProfile(Long userId) {
}

// TODO: 이후 AchievementException 구현 시 추가 필요!
@Transactional
public UserUpdateRes updateUserInfos(Long userId, UserUpdateReq request) {
User user = userCommonService.getUserById(userId);
Achievement achievement = achievementRepository.findById(request.getAchievementId())
Expand Down
Loading