Skip to content

Commit 613956d

Browse files
authored
Merge pull request #232 from prgrms-web-devcourse-final-project/feat#229
[feat] User 엔티티 id 조회로 equals 비교하도록 오버라이딩 기능 추가 #229
2 parents e8a08db + 14b67e7 commit 613956d

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

src/main/java/com/back/domain/user/entity/User.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.ArrayList;
1515
import java.util.Collection;
1616
import java.util.List;
17+
import java.util.Objects;
1718

1819
@Entity
1920
@Table(name = "users") // 예약어 충돌 방지를 위해 "users" 권장
@@ -70,6 +71,17 @@ public class User {
7071
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
7172
private List<PostLike> postLikes = new ArrayList<>();
7273

74+
@Override
75+
public boolean equals(Object o) {
76+
if (o == null || getClass() != o.getClass()) return false;
77+
User user = (User) o;
78+
return Objects.equals(id, user.id);
79+
}
80+
81+
@Override
82+
public int hashCode() {
83+
return Objects.hashCode(id);
84+
}
7385

7486
public boolean isAdmin() {
7587
return "ADMIN".equalsIgnoreCase(role);

src/main/java/com/back/global/security/SecurityUser.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public SecurityUser(
3838
authorities
3939
);
4040

41-
4241
this.id = id;
4342
this.nickname = nickname;
4443
this.email = email;

src/main/resources/application-dev.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@ spring:
2929
encoding: UTF-8
3030
data-locations: classpath:data-h2.sql
3131

32-
cloud:
33-
aws:
34-
region:
35-
static: ap-northeast-2
36-
stack:
37-
auto: false
38-
credentials:
39-
access-key: ${AWS_ACCESS_KEY_ID} # 로컬용 더미값
40-
secret-key: ${AWS_SECRET_ACCESS_KEY}
41-
s3:
42-
bucket: team2-app-s3-bucket
4332

4433
# Swagger 설정
4534
springdoc:

src/main/resources/application.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ spring:
4747
user-info-uri: https://openapi.naver.com/v1/nid/me
4848
user-name-attribute: response
4949

50+
cloud:
51+
aws:
52+
region:
53+
static: ap-northeast-2
54+
stack:
55+
auto: false
56+
credentials:
57+
access-key: ${AWS_ACCESS_KEY_ID} # 로컬용 더미값
58+
secret-key: ${AWS_SECRET_ACCESS_KEY}
59+
s3:
60+
bucket: team2-app-s3-bucket
61+
5062
ai:
5163
openai:
5264
api-key: ${GEMINI_API_KEY}

0 commit comments

Comments
 (0)