From df05255845a39fe57e2563828281bc51317319ac Mon Sep 17 00:00:00 2001 From: hoyun06 <97820785+hoyun06@users.noreply.github.com> Date: Tue, 10 Oct 2023 14:22:21 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=20User=20=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=EC=97=90=EC=84=9C=20provider=20=ED=95=84=EB=93=9C=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=20(#165)=20(#167)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: User에서 provider 제거 (#165) * refactor: User에서 provider 제거함에 따른 변경 사항 (#165) --- .../controller/UserApiController.java | 1 - .../com/newfit/reservation/domain/User.java | 23 ++----------------- .../reservation/service/UserService.java | 3 ++- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/newfit/reservation/controller/UserApiController.java b/src/main/java/com/newfit/reservation/controller/UserApiController.java index 5fd64b08..e1ffca61 100644 --- a/src/main/java/com/newfit/reservation/controller/UserApiController.java +++ b/src/main/java/com/newfit/reservation/controller/UserApiController.java @@ -52,7 +52,6 @@ public ResponseEntity drop(Authentication authentication, @PostMapping public ResponseEntity signUp(@RequestHeader(value = "oauth-history-id") Long oauthHistoryId, @Valid @RequestBody UserSignUpRequest request) { - // TODO: 권한 확인 로직 추가해야함. 근데 여기서 굳이 필요한 지는 모르겠음 userService.signUp(oauthHistoryId, request); return ResponseEntity .status(CREATED) diff --git a/src/main/java/com/newfit/reservation/domain/User.java b/src/main/java/com/newfit/reservation/domain/User.java index 647154d5..d1a9a626 100644 --- a/src/main/java/com/newfit/reservation/domain/User.java +++ b/src/main/java/com/newfit/reservation/domain/User.java @@ -11,7 +11,6 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; - import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -50,12 +49,6 @@ public class User extends BaseTimeEntity { @Column(nullable = false, unique = true) private String nickname; - // 사용자가 Oauth 2.0 로그인할 때 이용한 OAuth 제공자를 나타냅니다. - // Provider 라는 Enum 타입을 새로 정의했습니다. - @Enumerated(EnumType.STRING) - @Column(nullable = false) - private Provider provider; - // 사용자의 크레딧 잔여량을 나타냅니다. @Column(nullable = false) private Long balance; @@ -82,33 +75,23 @@ public class User extends BaseTimeEntity { /* =========== update method =========== */ public void updateEmail(String email) { - this.email = email; - } public void updateTel(String tel) { - this.tel = tel; - } public void updateNickname(String nickname) { - this.nickname = nickname; - } public void updateFilePath(String filePath) { - this.filePath = filePath; - } public void addBalance(Long balance) { - this.balance += balance; - } public Long getTermCredit(LocalDateTime term) { @@ -120,21 +103,19 @@ public Long getTermCredit(LocalDateTime term) { } @Builder - private User(UserSignUpRequest userInfo, Provider provider) { + private User(UserSignUpRequest userInfo) { this.username = userInfo.getUsername(); this.nickname = userInfo.getNickname(); this.email = userInfo.getEmail(); this.tel = userInfo.getTel(); - this.provider = provider; this.balance = 0L; this.lastLoginAt = LocalDateTime.now(); this.filePath = "https://newfit-image.s3.ap-northeast-2.amazonaws.com/newfitIcon.png"; } - public static User userSignUp(UserSignUpRequest request, Provider provider) { + public static User userSignUp(UserSignUpRequest request) { return User.builder() .userInfo(request) - .provider(provider) .build(); } } diff --git a/src/main/java/com/newfit/reservation/service/UserService.java b/src/main/java/com/newfit/reservation/service/UserService.java index 78bc3e15..03ee9f8a 100644 --- a/src/main/java/com/newfit/reservation/service/UserService.java +++ b/src/main/java/com/newfit/reservation/service/UserService.java @@ -21,6 +21,7 @@ import java.util.List; import static com.newfit.reservation.exception.ErrorCode.*; + @Service @RequiredArgsConstructor @Transactional @@ -86,7 +87,7 @@ public void signUp(Long oauthHistoryId, UserSignUpRequest request) { OAuthHistory oAuthHistory = oAuthHistoryRepository .findById(oauthHistoryId) .orElseThrow(() -> new CustomException(OAUTH_HISTORY_NOT_FOUND)); - User user = User.userSignUp(request, oAuthHistory.getProvider()); + User user = User.userSignUp(request); userRepository.save(user); oAuthHistory.signUp(user); }