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

fix: 채팅목록 조회 otherPeople 오류 #101

Merged
merged 2 commits into from
Jan 19, 2025
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
@@ -1,12 +1,14 @@
package com.hyunsolution.dangu.chatRoom.domain;

import java.util.List;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface ChatRoomRepository extends JpaRepository<ChatRoom, Long> {
@EntityGraph(attributePaths = {"participants.user"})
@Query(
"select c from ChatRoom c join fetch c.participants p join fetch p.user u where u.id = :userId")
"select c from ChatRoom c where exists (select 1 from Participant p where p.chatRoom = c and p.user.id = :userId)")
List<ChatRoom> findByParticipantUserIdWithEntityGraph(Long userId);

@Query(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public LoginResponse login(String uid, String password) {
return new LoginResponse(newUser.getId());
}
// 비밀번호 일치 확인
if (isMatchPassword(loginUser.get(), password)) {
if (isMatchPassword(password, loginUser.get())) {
return new LoginResponse(loginUser.get().getId());
} else {
throw UserWrongPasswordException.USER_WRONG_PASSWORD_EXCEPTION;
Expand All @@ -38,7 +38,7 @@ public User registerUser(String uid, String password) {
User.builder().uid(uid).password(passwordEncoder.encode(password)).build());
}

private boolean isMatchPassword(User loginUser, String encodedPassword) {
return passwordEncoder.matches(loginUser.getPassword(), encodedPassword);
private boolean isMatchPassword(String rawPwd, User loginUser) {
return passwordEncoder.matches(rawPwd, loginUser.getPassword());
}
}
Loading