Skip to content

Commit 9cf6aca

Browse files
committed
feat: ProfileMusic 테이블 수정 #21
- 단방향 방향을 Profile -> User에서 반대로 변경 - ProfileMusic에서 User 컬럼 제거 - User 컬럼에서 ProfileMusic 컬럼 추가 (OneToOne) - 이제부터 User 회원가입 시, Null값으로 프로필도 생성
1 parent ce38f4d commit 9cf6aca

File tree

5 files changed

+37
-4
lines changed

5 files changed

+37
-4
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import jakarta.persistence.Id;
55
import lombok.Builder;
66
import lombok.Getter;
7-
import lombok.NoArgsConstructor;
87
import org.dfbf.soundlink.domain.emotionRecord.entity.SpotifyMusic;
98
import org.hibernate.annotations.CreationTimestamp;
109
import org.hibernate.annotations.UpdateTimestamp;
@@ -13,7 +12,6 @@
1312

1413
@Entity
1514
@Getter
16-
@NoArgsConstructor
1715
public class ProfileMusic {
1816
@Id
1917
@GeneratedValue(strategy = GenerationType.IDENTITY)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.dfbf.soundlink.domain.user.repository;
22

3+
import org.dfbf.soundlink.domain.user.dto.response.UserMyPageDto;
34
import org.dfbf.soundlink.domain.user.entity.User;
45
import org.springframework.data.jpa.repository.JpaRepository;
56
import org.springframework.data.jpa.repository.Query;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.dfbf.soundlink.domain.user.repository.dsl;
2+
3+
import org.dfbf.soundlink.domain.user.dto.response.UserMyPageDto;
4+
import org.dfbf.soundlink.domain.user.entity.User;
5+
import org.springframework.data.repository.query.Param;
6+
7+
import java.util.Optional;
8+
9+
public interface UserCustomerRepository {
10+
11+
UserMyPageDto findMyPageDtoByUserId(@Param("user") User user);
12+
13+
Optional<UserMyPageDto> findMyPageDtoByLoginId(@Param("loginId") String loginId);
14+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.dfbf.soundlink.domain.user.repository.dsl;
2+
3+
import com.querydsl.jpa.impl.JPAQueryFactory;
4+
import lombok.RequiredArgsConstructor;
5+
import org.dfbf.soundlink.domain.user.dto.response.UserMyPageDto;
6+
import org.springframework.stereotype.Repository;
7+
8+
import java.util.Optional;
9+
10+
@Repository
11+
@RequiredArgsConstructor
12+
public class UserQueryRepository implements UserCustomerRepository {
13+
private final JPAQueryFactory jpaQueryFactory;
14+
15+
@Override
16+
Optional<UserMyPageDto> findMyPageDtoByLoginId(String loginId) {
17+
return Optional.empty();
18+
}
19+
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.dfbf.soundlink.domain.user.dto.request.UserUpdateDto;
1515
import org.dfbf.soundlink.domain.user.dto.response.UserGetDto;
1616
import org.dfbf.soundlink.domain.user.dto.response.UserMyPageDto;
17+
import org.dfbf.soundlink.domain.user.entity.ProfileMusic;
1718
import org.dfbf.soundlink.domain.user.entity.User;
1819
import org.dfbf.soundlink.domain.user.exception.NoUserDataException;
1920
import org.dfbf.soundlink.domain.user.repository.ProfileMusicRepository;
@@ -85,6 +86,7 @@ public ResponseResult updateUser(Long userId, UserUpdateDto userUpdateDto) {
8586

8687
try {
8788
User user = userRepository.findById(userId).orElseThrow(NoUserDataException::new);
89+
user.update(userUpdateDto, passwordEncoder);
8890

8991
// SpotifyMusic 객체 찾기 (없으면 새로 생성 & 저장)
9092
SpotifyMusic spotifyMusic = spotifyMusicRepository.findById(userUpdateDto.spotifyId())
@@ -108,6 +110,7 @@ public ResponseResult deleteUser(Long userId) {
108110
try {
109111
User user = userRepository.findById(userId).orElseThrow(() -> new NoUserDataException());
110112

113+
profileMusicRepository.deleteByUser(user); // 유저 프로필 음악 삭제
111114
emotionRecordRepository.deleteByUser(user); // 유저 감정 기록 삭제
112115
userRepository.deleteById(userId); // 유저 삭제
113116

@@ -283,8 +286,6 @@ public ResponseResult getProfile(String tag) {
283286
public ResponseResult reissueToken(HttpServletRequest request, HttpServletResponse response) {
284287
String accessToken = jwtProvider.resolveAccessToken(request);
285288
String refreshToken = jwtProvider.resolveRefreshToken(request);
286-
System.out.println("AccessToken: " + accessToken);
287-
System.out.println("RefreshToken from Cookie: " + refreshToken);
288289

289290
// System.out.println("AccessToken: " + accessToken);
290291
// System.out.println("RefreshToken from Cookie: " + refreshToken);

0 commit comments

Comments
 (0)