From 2db55f638526eddafd00b4b9f0585aac44f6c350 Mon Sep 17 00:00:00 2001 From: woosung1223 Date: Thu, 3 Oct 2024 17:14:39 +0900 Subject: [PATCH] =?UTF-8?q?:bug:=20fix:=20=EC=A4=91=EB=B3=B5=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=EB=A5=BC=20=EB=B0=98=ED=99=98=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../khu/toyouserver/application/UserService.java | 1 + .../java/slvtwn/khu/toyouserver/domain/User.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/main/java/slvtwn/khu/toyouserver/application/UserService.java b/src/main/java/slvtwn/khu/toyouserver/application/UserService.java index 64c5022..9179b81 100644 --- a/src/main/java/slvtwn/khu/toyouserver/application/UserService.java +++ b/src/main/java/slvtwn/khu/toyouserver/application/UserService.java @@ -63,6 +63,7 @@ private List 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(); } diff --git a/src/main/java/slvtwn/khu/toyouserver/domain/User.java b/src/main/java/slvtwn/khu/toyouserver/domain/User.java index 1c3683c..798558a 100644 --- a/src/main/java/slvtwn/khu/toyouserver/domain/User.java +++ b/src/main/java/slvtwn/khu/toyouserver/domain/User.java @@ -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; @@ -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); + } }