Skip to content

Commit

Permalink
🐛 fix: 중복 사용자를 반환하지 않도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
woosung1223 committed Oct 3, 2024
1 parent 76ac74f commit 2db55f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ private List<UserResponse> findAllUsersWithSameGroups(User user, String search)
.flatMap(List::stream)
.filter(each -> !each.getUser().getId().equals(user.getId()))
.map(each -> UserResponse.of(each.getUser(), each.getGroup().getId()))
.distinct()
.toList();
}

Expand Down
14 changes: 14 additions & 0 deletions src/main/java/slvtwn/khu/toyouserver/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.time.LocalDate;
import java.util.Objects;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down Expand Up @@ -57,4 +58,17 @@ public User updateInfo(String name, LocalDate birthday, String introduction, Str
this.profilePicture = profilePicture;
return this;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
return Objects.equals(id, user.id) && Objects.equals(name, user.name);
}

@Override
public int hashCode() {
return Objects.hash(id, name);
}
}

0 comments on commit 2db55f6

Please sign in to comment.