diff --git a/src/main/java/com/sopterm/makeawish/domain/user/AccountInfo.java b/src/main/java/com/sopterm/makeawish/domain/user/AccountInfo.java index 88603ad..fda75ec 100644 --- a/src/main/java/com/sopterm/makeawish/domain/user/AccountInfo.java +++ b/src/main/java/com/sopterm/makeawish/domain/user/AccountInfo.java @@ -16,8 +16,16 @@ public class AccountInfo { private String name; private String bank; private String account; + private String kakaoPayCode; + private boolean forPayCode; - public AccountInfo updateInfo(String name, String bank, String account) { + public AccountInfo updateInfo(String name, String bank, String account, String kakaoPayCode) { + if(nonNull(account) && !this.account.equals(account)) { + this.forPayCode = false; + } + if(nonNull(kakaoPayCode) && !this.kakaoPayCode.equals(kakaoPayCode)) { + this.forPayCode = true; + } if (nonNull(name)) { this.name = name; } @@ -25,8 +33,14 @@ public AccountInfo updateInfo(String name, String bank, String account) { this.bank = bank; } if (nonNull(account)) { + this.forPayCode = false; this.account = account; } + + if(nonNull(kakaoPayCode)) { + this.forPayCode = true; + this.kakaoPayCode = kakaoPayCode; + } return this; } } diff --git a/src/main/java/com/sopterm/makeawish/domain/user/User.java b/src/main/java/com/sopterm/makeawish/domain/user/User.java index 0702821..af2095d 100644 --- a/src/main/java/com/sopterm/makeawish/domain/user/User.java +++ b/src/main/java/com/sopterm/makeawish/domain/user/User.java @@ -50,8 +50,6 @@ public class User { @Embedded private AccountInfo account; - private String phoneNumber; - @OneToMany(mappedBy = "wisher") private final List wishes = new ArrayList<>(); @@ -62,28 +60,21 @@ public User(AuthSignInRequestDTO authSignInRequestDto) { this.socialId = authSignInRequestDto.socialId(); this.nickname = authSignInRequestDto.nickname(); this.createdAt = authSignInRequestDto.createdAt(); - this.account = new AccountInfo(null, null, null); + this.account = new AccountInfo(null, null, null, null, false); } public void updateRefreshToken(String refreshToken) { this.refreshToken = refreshToken; } - public void updateProfile(String name, String bank, String account, String phoneNumber) { - updatePhoneNumber(phoneNumber); - updateAccount(name, bank, account); - } - - public void updatePhoneNumber(String phoneNumber) { - if (nonNull(phoneNumber)) { - this.phoneNumber = phoneNumber; - } + public void updateProfile(String name, String bank, String account, String kakaoPayCode) { + updateAccount(name, bank, account, kakaoPayCode); } - public void updateAccount(String name, String bank, String account) { + public void updateAccount(String name, String bank, String account, String kakaoPayCode) { if (isNull(this.account)) { - this.account = new AccountInfo(null, null, null); + this.account = new AccountInfo(null, null, null, null, false); } - this.account.updateInfo(name, bank, account); + this.account.updateInfo(name, bank, account, kakaoPayCode); } } \ No newline at end of file diff --git a/src/main/java/com/sopterm/makeawish/dto/user/UserAccountResponseDTO.java b/src/main/java/com/sopterm/makeawish/dto/user/UserAccountResponseDTO.java index 6367d41..5de2a75 100644 --- a/src/main/java/com/sopterm/makeawish/dto/user/UserAccountResponseDTO.java +++ b/src/main/java/com/sopterm/makeawish/dto/user/UserAccountResponseDTO.java @@ -9,14 +9,12 @@ @Builder public record UserAccountResponseDTO( Long id, - AccountInfo accountInfo, - String phone + AccountInfo accountInfo ) { public static UserAccountResponseDTO of(User user) { return UserAccountResponseDTO.builder() .id(user.getId()) .accountInfo(getUserAccount(user)) - .phone(user.getPhoneNumber()) .build(); } diff --git a/src/main/java/com/sopterm/makeawish/dto/wish/UserWishResponseDTO.java b/src/main/java/com/sopterm/makeawish/dto/wish/UserWishResponseDTO.java index 9403a3c..1b9bc98 100644 --- a/src/main/java/com/sopterm/makeawish/dto/wish/UserWishResponseDTO.java +++ b/src/main/java/com/sopterm/makeawish/dto/wish/UserWishResponseDTO.java @@ -16,7 +16,6 @@ public static UserWishResponseDTO of(Wish wish) { .title(wish.getTitle()) .startAt(wish.getStartAt().toString()) .endAt(wish.getEndAt().toString()) - .build(); } } diff --git a/src/main/java/com/sopterm/makeawish/dto/wish/UserWishUpdateRequestDTO.java b/src/main/java/com/sopterm/makeawish/dto/wish/UserWishUpdateRequestDTO.java index 218e966..e35b39a 100644 --- a/src/main/java/com/sopterm/makeawish/dto/wish/UserWishUpdateRequestDTO.java +++ b/src/main/java/com/sopterm/makeawish/dto/wish/UserWishUpdateRequestDTO.java @@ -9,9 +9,9 @@ public record UserWishUpdateRequestDTO( String name, String bankName, String account, - String phone, String imageUrl, String title, - boolean wantsGift + boolean wantsGift, + String kakaoPayCode ) { } diff --git a/src/main/java/com/sopterm/makeawish/dto/wish/UserWishUpdateResponseDTO.java b/src/main/java/com/sopterm/makeawish/dto/wish/UserWishUpdateResponseDTO.java index 011ed22..489da3f 100644 --- a/src/main/java/com/sopterm/makeawish/dto/wish/UserWishUpdateResponseDTO.java +++ b/src/main/java/com/sopterm/makeawish/dto/wish/UserWishUpdateResponseDTO.java @@ -13,7 +13,6 @@ public record UserWishUpdateResponseDTO( String startDate, String endDate, - String phone, AccountInfo accountInfo, String imageUrl, String title, @@ -23,7 +22,6 @@ public static UserWishUpdateResponseDTO of(User user, Wish wish) { return UserWishUpdateResponseDTO.builder() .startDate(wish.getStartAt().toString()) .endDate(wish.getEndAt().toString()) - .phone(user.getPhoneNumber()) .accountInfo(nonNull(user.getAccount()) ? user.getAccount() : null) .imageUrl(wish.getPresentImageUrl()) .title(wish.getTitle()) diff --git a/src/main/java/com/sopterm/makeawish/dto/wish/WishRequestDTO.java b/src/main/java/com/sopterm/makeawish/dto/wish/WishRequestDTO.java index 62546e8..7e72bd3 100644 --- a/src/main/java/com/sopterm/makeawish/dto/wish/WishRequestDTO.java +++ b/src/main/java/com/sopterm/makeawish/dto/wish/WishRequestDTO.java @@ -10,13 +10,11 @@ public record WishRequestDTO( String title, String startDate, String endDate, - String phone, boolean wantsGift, String hint ) { public Wish toEntity(User wisher) { - wisher.updatePhoneNumber(phone); return Wish.builder() .presentImageUrl(imageUrl) .hint(hint) diff --git a/src/main/java/com/sopterm/makeawish/dto/wish/WishResponseDTO.java b/src/main/java/com/sopterm/makeawish/dto/wish/WishResponseDTO.java index 62c2c6d..595a5fe 100644 --- a/src/main/java/com/sopterm/makeawish/dto/wish/WishResponseDTO.java +++ b/src/main/java/com/sopterm/makeawish/dto/wish/WishResponseDTO.java @@ -12,7 +12,7 @@ import org.apache.commons.lang3.StringUtils; @Builder -public record WishResponseDTO(String name, long dayCount, String title, String hint, String bank, String accountNumber, boolean wantsGift, String presentImageUrl) { +public record WishResponseDTO(String name, long dayCount, String title, String hint, String bank, String accountNumber, boolean wantsGift, String presentImageUrl, String kakaoPayCode, boolean forPayCode) { public static WishResponseDTO from(Wish wish) { val name = nonNull(wish.getWisher().getAccount()) @@ -26,10 +26,16 @@ public static WishResponseDTO from(Wish wish) { ? wish.getWisher().getAccount().getBank() : StringUtils.EMPTY; + val kakaoPayCode = nonNull(wish.getWisher().getAccount().getKakaoPayCode()) + ? wish.getWisher().getAccount().getKakaoPayCode() + : StringUtils.EMPTY; + return WishResponseDTO.builder() .name(name) .accountNumber(account) .bank(bank) + .kakaoPayCode(kakaoPayCode) + .forPayCode(wish.getWisher().getAccount().isForPayCode()) .dayCount(getRemainDayCount(wish.getEndAt())) .title(wish.getTitle()) .hint(wish.getHint()) diff --git a/src/main/java/com/sopterm/makeawish/service/UserService.java b/src/main/java/com/sopterm/makeawish/service/UserService.java index a17cc69..44d39ee 100644 --- a/src/main/java/com/sopterm/makeawish/service/UserService.java +++ b/src/main/java/com/sopterm/makeawish/service/UserService.java @@ -51,8 +51,8 @@ public UserAccountResponseDTO updateUserAccount(Long userId, UserAccountRequestD wisher.updateAccount( requestDTO.accountInfo().getName(), requestDTO.accountInfo().getBank(), - requestDTO.accountInfo().getAccount()); - wisher.updatePhoneNumber(requestDTO.phone()); + requestDTO.accountInfo().getAccount(), + requestDTO.accountInfo().getKakaoPayCode()); return UserAccountResponseDTO.of(wisher); } diff --git a/src/main/java/com/sopterm/makeawish/service/WishService.java b/src/main/java/com/sopterm/makeawish/service/WishService.java index ba42bb9..948ea79 100644 --- a/src/main/java/com/sopterm/makeawish/service/WishService.java +++ b/src/main/java/com/sopterm/makeawish/service/WishService.java @@ -64,9 +64,7 @@ public Long createWish(Long userId, WishRequestDTO requestDTO) { } catch (RuntimeException e) { log.error(SlackErrorMessage.POST_REQUEST_ERROR.getMessage() + e.getMessage()); } - Long wishId = wishRepository.save(wish).getId(); - presentRepository.save(Present.initAdminPresent(wish)); - return wishId; + return wishRepository.save(wish).getId(); } public WishResponseDTO findWish(Long wishId) throws AccessDeniedException { @@ -131,7 +129,7 @@ public UserWishUpdateResponseDTO updateUserMainWish(Long userId, UserWishUpdateR } if (status.equals(BEFORE) || status.equals(WHILE)) { wish.updateContent(request.imageUrl(), request.title(), request.wantsGift()); - wisher.updateProfile(request.name(), request.bankName(), request.account(), request.phone()); + wisher.updateProfile(request.name(), request.bankName(), request.account(), request.kakaoPayCode()); } return UserWishUpdateResponseDTO.of(wisher, wish); diff --git a/src/test/java/com/sopterm/makeawish/config/CacheTest.java b/src/test/java/com/sopterm/makeawish/config/CacheTest.java index a33b0bb..50585da 100644 --- a/src/test/java/com/sopterm/makeawish/config/CacheTest.java +++ b/src/test/java/com/sopterm/makeawish/config/CacheTest.java @@ -57,7 +57,7 @@ private String getLocalDateTime(int plusDays) { private User createUser() { - AccountInfo accountInfo = new AccountInfo("김아무", "bank", "account"); + AccountInfo accountInfo = new AccountInfo("김아무", "bank", "account", "kakaoPayCode", true); return User.builder() .email("kim@email.com") .socialType(SocialType.KAKAO) diff --git a/src/test/java/com/sopterm/makeawish/service/CakeServiceTest.java b/src/test/java/com/sopterm/makeawish/service/CakeServiceTest.java index 25d6c3b..70b9100 100644 --- a/src/test/java/com/sopterm/makeawish/service/CakeServiceTest.java +++ b/src/test/java/com/sopterm/makeawish/service/CakeServiceTest.java @@ -131,7 +131,7 @@ private String getLocalDateTime(int plusDays){ private User createUser(){ - AccountInfo accountInfo = new AccountInfo("김아무", "bank", "account"); + AccountInfo accountInfo = new AccountInfo("김아무", "bank", "account", "kakaoPayCode", false); return User.builder() .email("kim@email.com") .socialType(SocialType.KAKAO)