Skip to content

Commit a935fc8

Browse files
committed
fix: entity 수정
- user에서 nickName 퀄럼을 nickname으로 변경 - entity의 모든 퀄럼에 @column(name = ~) 추가
1 parent 2e57c6a commit a935fc8

File tree

8 files changed

+43
-23
lines changed

8 files changed

+43
-23
lines changed

src/main/java/org/dfbf/soundlink/domain/blocklist/entity/Blocklist.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class Blocklist {
1818

1919
@Id
2020
@GeneratedValue(strategy = GenerationType.IDENTITY)
21+
@Column(name = "blocklist_id")
2122
private Long blocklistId;
2223

2324
@ManyToOne
@@ -29,9 +30,11 @@ public class Blocklist {
2930
private User blockedUser;
3031

3132
@CreationTimestamp
33+
@Column(name = "created_at")
3234
private Timestamp createdAt;
3335

3436
@UpdateTimestamp
37+
@Column(name = "updated_at")
3538
private Timestamp updatedAt;
3639

3740
@Builder

src/main/java/org/dfbf/soundlink/domain/emotionRecord/entity/EmotionRecord.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,30 @@
1616
public class EmotionRecord {
1717
@Id
1818
@GeneratedValue(strategy = GenerationType.IDENTITY)
19+
@Column(name = "record_id")
1920
private Long recordId;
2021

2122
@ManyToOne
2223
@JoinColumn(name = "user_id")
2324
private User user;
2425

2526
@Enumerated(EnumType.STRING)
27+
@Column(name = "emotion")
2628
private Emotions emotion;
2729

2830
@ManyToOne
2931
@JoinColumn(name = "spotify_music_id")
3032
private SpotifyMusic spotifyMusic;
3133

34+
@Column(name = "comment")
3235
private String comment;
3336

3437
@CreationTimestamp
38+
@Column(name = "created_at")
3539
private Timestamp createdAt;
3640

3741
@UpdateTimestamp
42+
@Column(name = "updated_at")
3843
private Timestamp updatedAt;
3944

4045
@Builder

src/main/java/org/dfbf/soundlink/domain/emotionRecord/entity/SpotifyMusic.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,25 @@
1515
@NoArgsConstructor(access = AccessLevel.PROTECTED)
1616
public class SpotifyMusic {
1717
@Id
18+
@GeneratedValue(strategy = GenerationType.IDENTITY)
1819
private Long spotifyId;
1920

21+
@Column(name = "title")
2022
private String title;
23+
24+
@Column(name = "artist")
2125
private String artist;
26+
27+
@Column(name = "album_image")
2228
private String albumImage;
2329

2430
@CreationTimestamp
31+
@Column(name = "created_at")
2532
private Timestamp createdAt;
33+
2634
@UpdateTimestamp
27-
private Timestamp updateAt;
35+
@Column(name = "updated_at")
36+
private Timestamp updatedAt;
2837

2938
@Builder
3039
public SpotifyMusic (Long spotifyId, String title, String artist, String albumImage) {

src/main/java/org/dfbf/soundlink/domain/user/dto/response/UserGetDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public record UserGetDto(
1212
) {
1313
public UserGetDto(User user) {
1414
this(
15-
user.getNickName(),
15+
user.getNickname(),
1616
user.getEmail(),
1717
user.getLoginId(),
1818
formatTimestamp(user.getCreatedAt())

src/main/java/org/dfbf/soundlink/domain/user/entity/ProfileMusic.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
public class ProfileMusic {
1818
@Id
1919
@GeneratedValue(strategy = GenerationType.IDENTITY)
20+
@JoinColumn(name = "profile_music_id")
2021
private Long profileMusicId;
2122

2223
@OneToOne(cascade = CascadeType.REMOVE)
@@ -28,9 +29,12 @@ public class ProfileMusic {
2829
private SpotifyMusic spotifyMusic;
2930

3031
@CreationTimestamp
31-
private Timestamp createAt;
32+
@Column(name = "created_at")
33+
private Timestamp createdAt;
34+
3235
@UpdateTimestamp
33-
private Timestamp updateAt;
36+
@Column(name = "updated_at")
37+
private Timestamp updatedAt;
3438

3539
@Builder
3640
public ProfileMusic(User user, SpotifyMusic spotifyMusic) {

src/main/java/org/dfbf/soundlink/domain/user/entity/User.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,39 @@
1919
public class User {
2020
@Id
2121
@GeneratedValue(strategy = GenerationType.IDENTITY)
22+
@Column(name = "user_id")
2223
private Long userId;
2324

24-
@Column(unique = true)
25-
private String nickName;
25+
@Column(name = "nickname", unique = true)
26+
private String nickname;
2627

2728
@Enumerated(EnumType.STRING)
29+
@Column(name = "social_type")
2830
private SocialType socialType;
2931

30-
@Column(nullable = true)
32+
@Column(name = "social_id", nullable = true)
3133
private Long socialId;
3234

3335
@Column(name="login_id")
3436
private String loginId;
3537

38+
@Column(name="password")
3639
private String password;
37-
private String email;
38-
39-
@OneToMany(mappedBy = "user", cascade = CascadeType.REMOVE)
40-
private List<Blocklist> blocklist;
41-
42-
@OneToMany(mappedBy = "user", cascade = CascadeType.REMOVE)
43-
private List<EmotionRecord> emotionRecord;
4440

45-
@OneToOne(mappedBy = "user", cascade = CascadeType.REMOVE)
46-
private ProfileMusic profileMusic;
41+
@Column(name="email")
42+
private String email;
4743

4844
@CreationTimestamp
45+
@Column(name = "created_at")
4946
private Timestamp createdAt;
47+
5048
@UpdateTimestamp
51-
private Timestamp updateAt;
49+
@Column(name = "updated_at")
50+
private Timestamp updatedAt;
5251

5352
@Builder
5453
User(String nickName, Long socialId, SocialType socialType, String loginId, String password, String email) {
55-
this.nickName = nickName;
54+
this.nickname = nickName;
5655
this.socialId = socialId;
5756
this.socialType = socialType;
5857
this.loginId = loginId;
@@ -61,7 +60,7 @@ public class User {
6160
}
6261

6362
public void update(UserUpdateDto userUpdateDto, BCryptPasswordEncoder passwordEncoder) {
64-
this.nickName = userUpdateDto.nickName();
63+
this.nickname = userUpdateDto.nickName();
6564
this.loginId = userUpdateDto.loginId();
6665
this.password = passwordEncoder.encode(userUpdateDto.password());
6766
this.email = userUpdateDto.email();
@@ -81,6 +80,6 @@ public void update(UserUpdateDto userUpdateDto, BCryptPasswordEncoder passwordEn
8180
* CascadeType.REMOVE -> 부모 엔티티가 삭제될 때 자식 엔티티는 삭제
8281
* orphanRemoval = true -> 자식 엔티티가 부모와의 관계에서 제거될 때 삭제
8382
* 가끔 사용하지 않는 데이터가 DB에 남아있는 경우가 있는데, 이를 방지하기 위해 사용
84-
* 혹은 User쪽에 있는 리스트에서 제거할 경우, 양방향 매핑이기 떄문에 자식이 고아가 댐 -> 이를 위헤서 orphanRemoval를 사용
83+
* 혹은 User쪽에 있는 리스트에서 제거할 경우, 양방향 매핑이기 떄문에 자식이 고아가 댐 -> 이를 위헤서 orphanRemoval를 사용
8584
* 근데 우린 사용 안하니까 사실 빼도 무방할 듯....
8685
*/

src/main/java/org/dfbf/soundlink/domain/user/repository/UserRepository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
public interface UserRepository extends JpaRepository<User, Long> {
1212
boolean existsByEmail(String email);
1313

14-
boolean existsByNickName(String nickName);
14+
boolean existsByNickname(String nickName);
1515

1616
Optional<User> findById(Long id);
1717

1818
// JPQL에서는 Inner Class에 직접 값을 넣을 수 있도록 하는 기능은 지원하지 않는다.
1919
@Query(
2020
"SELECT new org.dfbf.soundlink.domain.user.dto.response.UserMyPageDto(" +
21-
"u.email, u.loginId, u.nickName," +
21+
"u.email, u.loginId, u.nickname," +
2222
"new org.dfbf.soundlink.domain.user.dto.response.ProfileMusic(" +
2323
"pm.spotifyMusic.spotifyId, pm.spotifyMusic.title, pm.spotifyMusic.artist, pm.spotifyMusic.albumImage)) " +
2424
"FROM User u " +

src/main/java/org/dfbf/soundlink/domain/user/service/UserService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public ResponseResult checkEmail(String email){
169169

170170
//닉네임 중복 확인
171171
public ResponseResult checkNickName(String nickName){
172-
boolean exists =userRepository.existsByNickName(nickName);
172+
boolean exists =userRepository.existsByNickname(nickName);
173173
if(exists){
174174
return new ResponseResult(ErrorCode.DUPLICATE_NICKNAME);
175175
}

0 commit comments

Comments
 (0)