From fbb65e834a8d421e8e872ff5cf80cb096e6cec35 Mon Sep 17 00:00:00 2001 From: geneaky Date: Thu, 19 Sep 2024 01:25:59 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../toy/bookchat/bookchat/domain/user/User.java | 4 +++- .../domain/user/api/v1/UserController.java | 8 ++++---- .../user/api/v1/response/UserProfileResponse.java | 14 +++++++------- .../bookchat/domain/user/service/UserReader.java | 1 + .../bookchat/domain/user/service/UserService.java | 9 ++++----- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/main/java/toy/bookchat/bookchat/domain/user/User.java b/src/main/java/toy/bookchat/bookchat/domain/user/User.java index a44de40b..2f992942 100644 --- a/src/main/java/toy/bookchat/bookchat/domain/user/User.java +++ b/src/main/java/toy/bookchat/bookchat/domain/user/User.java @@ -8,13 +8,15 @@ public class User { private final Long id; private final String nickname; + private final String email; private final String profileImageUrl; private final Integer defaultProfileImageType; @Builder - public User(Long id, String nickname, String profileImageUrl, Integer defaultProfileImageType) { + public User(Long id, String nickname, String email, String profileImageUrl, Integer defaultProfileImageType) { this.id = id; this.nickname = nickname; + this.email = email; this.profileImageUrl = profileImageUrl; this.defaultProfileImageType = defaultProfileImageType; } diff --git a/src/main/java/toy/bookchat/bookchat/domain/user/api/v1/UserController.java b/src/main/java/toy/bookchat/bookchat/domain/user/api/v1/UserController.java index 8e28fe77..30b2bc37 100644 --- a/src/main/java/toy/bookchat/bookchat/domain/user/api/v1/UserController.java +++ b/src/main/java/toy/bookchat/bookchat/domain/user/api/v1/UserController.java @@ -20,8 +20,7 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import toy.bookchat.bookchat.db_module.user.UserEntity; -import toy.bookchat.bookchat.support.RateLimit; -import toy.bookchat.bookchat.domain.user.UserProfile; +import toy.bookchat.bookchat.domain.user.User; import toy.bookchat.bookchat.domain.user.api.v1.request.ChangeUserNicknameRequest; import toy.bookchat.bookchat.domain.user.api.v1.request.UserSignInRequest; import toy.bookchat.bookchat.domain.user.api.v1.request.UserSignUpRequest; @@ -34,6 +33,7 @@ import toy.bookchat.bookchat.security.token.openid.IdTokenManager; import toy.bookchat.bookchat.security.user.TokenPayload; import toy.bookchat.bookchat.security.user.UserPayload; +import toy.bookchat.bookchat.support.RateLimit; @RequiredArgsConstructor @@ -55,8 +55,8 @@ public class UserController { */ @GetMapping("/users/profile") public UserProfileResponse userProfile(@UserPayload TokenPayload tokenPayload) { - UserProfile userProfile = userService.findUser(tokenPayload.getUserId()); - return UserProfileResponse.of(userProfile); + User user = userService.findUser(tokenPayload.getUserId()); + return UserProfileResponse.of(user); } /** diff --git a/src/main/java/toy/bookchat/bookchat/domain/user/api/v1/response/UserProfileResponse.java b/src/main/java/toy/bookchat/bookchat/domain/user/api/v1/response/UserProfileResponse.java index 0f414f0a..c18e7743 100644 --- a/src/main/java/toy/bookchat/bookchat/domain/user/api/v1/response/UserProfileResponse.java +++ b/src/main/java/toy/bookchat/bookchat/domain/user/api/v1/response/UserProfileResponse.java @@ -2,7 +2,7 @@ import lombok.Builder; import lombok.Getter; -import toy.bookchat.bookchat.domain.user.UserProfile; +import toy.bookchat.bookchat.domain.user.User; @Getter @Builder @@ -14,13 +14,13 @@ public class UserProfileResponse { private String userProfileImageUri; private Integer defaultProfileImageType; - public static UserProfileResponse of(UserProfile userProfile) { + public static UserProfileResponse of(User user) { return UserProfileResponse.builder() - .userId(userProfile.getUserId()) - .userNickname(userProfile.getUserNickname()) - .userEmail(userProfile.getUserEmail()) - .userProfileImageUri(userProfile.getUserProfileImageUri()) - .defaultProfileImageType(userProfile.getDefaultProfileImageType()) + .userId(user.getId()) + .userNickname(user.getNickname()) + .userEmail(user.getEmail()) + .userProfileImageUri(user.getProfileImageUrl()) + .defaultProfileImageType(user.getDefaultProfileImageType()) .build(); } } diff --git a/src/main/java/toy/bookchat/bookchat/domain/user/service/UserReader.java b/src/main/java/toy/bookchat/bookchat/domain/user/service/UserReader.java index 3d815cac..b1a4cf7b 100644 --- a/src/main/java/toy/bookchat/bookchat/domain/user/service/UserReader.java +++ b/src/main/java/toy/bookchat/bookchat/domain/user/service/UserReader.java @@ -35,6 +35,7 @@ public User readUser(Long userId) { return User.builder() .id(userEntity.getId()) .nickname(userEntity.getNickname()) + .email(userEntity.getEmail()) .profileImageUrl(userEntity.getProfileImageUrl()) .defaultProfileImageType(userEntity.getDefaultProfileImageType()) .build(); diff --git a/src/main/java/toy/bookchat/bookchat/domain/user/service/UserService.java b/src/main/java/toy/bookchat/bookchat/domain/user/service/UserService.java index 70a60aa6..8ec3d882 100644 --- a/src/main/java/toy/bookchat/bookchat/domain/user/service/UserService.java +++ b/src/main/java/toy/bookchat/bookchat/domain/user/service/UserService.java @@ -14,8 +14,7 @@ import toy.bookchat.bookchat.db_module.device.repository.DeviceRepository; import toy.bookchat.bookchat.db_module.user.UserEntity; import toy.bookchat.bookchat.db_module.user.repository.UserRepository; -import toy.bookchat.bookchat.infrastructure.s3.StorageService; -import toy.bookchat.bookchat.domain.user.UserProfile; +import toy.bookchat.bookchat.domain.user.User; import toy.bookchat.bookchat.domain.user.api.v1.request.ChangeUserNicknameRequest; import toy.bookchat.bookchat.domain.user.api.v1.request.UserSignInRequest; import toy.bookchat.bookchat.domain.user.api.v1.request.UserSignUpRequest; @@ -24,6 +23,7 @@ import toy.bookchat.bookchat.exception.conflict.device.DeviceAlreadyRegisteredException; import toy.bookchat.bookchat.infrastructure.fcm.PushMessageBody; import toy.bookchat.bookchat.infrastructure.fcm.service.PushService; +import toy.bookchat.bookchat.infrastructure.s3.StorageService; @Service public class UserService { @@ -154,8 +154,7 @@ public MemberProfileResponse getMemberProfile(Long memberId) { } @Transactional(readOnly = true) - public UserProfile findUser(Long userId) { - UserEntity userEntity = userReader.readUserEntity(userId); - return UserProfile.from(userEntity); + public User findUser(Long userId) { + return userReader.readUser(userId); } }