Skip to content

Commit c44a261

Browse files
authored
Merge pull request #124 from prgrms-web-devcourse-final-project/refactor
[REFACTOR]: User 연관관계 추가 및 OAuth·ErrorCode 정리
2 parents 92a1e6f + e354686 commit c44a261

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package com.back.domain.user.entity;
22

3+
import com.back.domain.comment.entity.Comment;
4+
import com.back.domain.like.entity.CommentLike;
5+
import com.back.domain.like.entity.PostLike;
36
import com.back.domain.node.entity.BaseLine;
47
import com.back.domain.node.entity.BaseNode;
58
import com.back.domain.node.entity.DecisionLine;
69
import com.back.domain.node.entity.DecisionNode;
10+
import com.back.domain.post.entity.Post;
711
import com.back.domain.scenario.entity.Scenario;
812
import com.back.global.baseentity.BaseEntity;
913
import jakarta.persistence.*;
@@ -87,4 +91,20 @@ public class User extends BaseEntity {
8791
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
8892
@Builder.Default
8993
private List<Scenario> scenarios = new ArrayList<>();
94+
95+
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
96+
@Builder.Default
97+
private List<Post> posts = new ArrayList<>();
98+
99+
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
100+
@Builder.Default
101+
private List<Comment> comments = new ArrayList<>();
102+
103+
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
104+
@Builder.Default
105+
private List<PostLike> postLikes = new ArrayList<>();
106+
107+
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
108+
@Builder.Default
109+
private List<CommentLike> commentLikes = new ArrayList<>();
90110
}

back/src/main/java/com/back/global/config/EmbeddedRedisConfig.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public void startRedis() {
3232
System.out.println("========================================");
3333
} catch (IOException e) {
3434
System.err.println("Embedded Redis start failed: " + e.getMessage());
35-
System.err.println("This is OK if external Redis is already running");
3635
}
3736
}
3837

back/src/main/java/com/back/global/exception/ErrorCode.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public enum ErrorCode {
2626
LOGIN_ID_DUPLICATION(HttpStatus.BAD_REQUEST, "U003", "Login ID Duplication"),
2727
INVALID_PASSWORD(HttpStatus.BAD_REQUEST, "U004", "Invalid Password"),
2828
UNAUTHORIZED_USER(HttpStatus.UNAUTHORIZED, "U005", "Unauthorized User"),
29-
NICKNAME_DUPLICATION(HttpStatus.CONFLICT, "U006", "이미 사용 중인 닉네임입니다."),
29+
NICKNAME_DUPLICATION(HttpStatus.CONFLICT, "U006", "Nickname Duplication"),
3030

3131
// Post Errors
3232
POST_NOT_FOUND(HttpStatus.NOT_FOUND, "P001", "Post Not Found"),
@@ -72,11 +72,11 @@ public enum ErrorCode {
7272

7373
// Poll Errors
7474
POLL_VOTE_NOT_FOUND(HttpStatus.NOT_FOUND, "PV001", "Poll Vote Not Found"),
75-
POLL_VOTE_INVALID_FORMAT(HttpStatus.BAD_REQUEST, "PV002", "투표 형식이 올바르지 않습니다."),
76-
POLL_VOTE_INVALID_OPTION(HttpStatus.BAD_REQUEST, "PV003", "존재하지 않는 투표 항목입니다." ),
75+
POLL_VOTE_INVALID_FORMAT(HttpStatus.BAD_REQUEST, "PV002", "Invalid Poll Format"),
76+
POLL_VOTE_INVALID_OPTION(HttpStatus.BAD_REQUEST, "PV003", "Invalid Poll Option" ),
7777

7878
// Lock Errors
79-
LOCK_ACQUISITION_FAILED(HttpStatus.CONFLICT, "L001", "다른 요청이 처리 중입니다. 잠시 후 다시 시도해주세요."),
79+
LOCK_ACQUISITION_FAILED(HttpStatus.CONFLICT, "L001", "Another request is being processed. Please try again later."),
8080

8181
// Storage Errors
8282
STORAGE_UPLOAD_FAILED(HttpStatus.INTERNAL_SERVER_ERROR, "ST001", "Failed to upload file to storage"),

back/src/main/java/com/back/global/security/oauth2/OAuthAttributes.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ public record OAuthAttributes(
1313
Map<String, Object> attributes,
1414
String nameAttributeKey,
1515
String name,
16-
String email,
17-
String picture
16+
String email
1817
) {
1918

2019
public static OAuthAttributes of(String registrationId, String userNameAttributeName, Map<String, Object> attributes) {
@@ -32,8 +31,7 @@ private static OAuthAttributes ofGoogle(String userNameAttributeName, Map<String
3231
attributes,
3332
userNameAttributeName,
3433
(String) attributes.get("name"),
35-
(String) attributes.get("email"),
36-
(String) attributes.get("picture")
34+
(String) attributes.get("email")
3735
);
3836
}
3937

@@ -47,8 +45,7 @@ private static OAuthAttributes ofGithub(String userNameAttributeName, Map<String
4745
attributes,
4846
userNameAttributeName,
4947
name,
50-
email,
51-
(String) attributes.get("avatar_url")
48+
email
5249
);
5350
}
5451
}

0 commit comments

Comments
 (0)