Skip to content

Commit

Permalink
[Feat] 마이페이지 응답값 가입일 -> 가입 디데이로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
funnysunny08 committed May 13, 2024
1 parent 0a6d982 commit b0c8fcf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.winey.server.controller.response.user;

import java.time.LocalDate;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand All @@ -19,7 +18,7 @@ public class UserResponseDto {
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public static class UserData {
private Long userId;
private LocalDate userCreatedAt;
private Long createdDday;
private String nickname;
private String userLevel;
private Boolean fcmIsAllowed;
Expand All @@ -31,11 +30,10 @@ public static class UserData {
private Long remainingCount;
}


public static UserResponseDto of(Long userId, LocalDate userCreatedAt, String nickname, String userLevel,
public static UserResponseDto of(Long userId, Long createdDday, String nickname, String userLevel,
Boolean fcmIsAllowed, Long accumulatedAmount,Long accumulatedCount, Long amountSavedTwoWeeks,
Long amountSpentTwoWeeks, Long remainingAmount, Long remainingCount) {
UserData userData = new UserData(userId, userCreatedAt, nickname, userLevel, fcmIsAllowed, accumulatedAmount, accumulatedCount,
UserData userData = new UserData(userId, createdDday, nickname, userLevel, fcmIsAllowed, accumulatedAmount, accumulatedCount,
amountSavedTwoWeeks, amountSpentTwoWeeks,remainingAmount,remainingCount);
return new UserResponseDto(userData);
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/winey/server/service/UserService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.winey.server.service;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -30,6 +31,7 @@ public UserResponseDto getUser(Long userId) {
Error.NOT_FOUND_USER_EXCEPTION.getMessage()));

LocalDateTime twoWeeksAgo = LocalDateTime.now().minusWeeks(2);
Long createdDday = Math.abs(ChronoUnit.DAYS.between(user.getCreatedAt(), LocalDateTime.now())) + 1;
Long amountSavedTwoWeeks = feedRepository.getSavedAmountForPeriod(user, twoWeeksAgo);
Long amountSpentTwoWeeks = feedRepository.getSpentAmountForPeriod(user, twoWeeksAgo);

Expand All @@ -41,7 +43,7 @@ public UserResponseDto getUser(Long userId) {
long remainingAmount = nextUserLevel == null ? 0L : nextUserLevel.getMinimumAmount() - savedAmountOfUser;
long remainingCount = nextUserLevel == null ? 0L : nextUserLevel.getMinimumCount() - savedCountOfUser;

return UserResponseDto.of(user.getUserId(), user.getCreatedAt().toLocalDate(), user.getNickname(),
return UserResponseDto.of(user.getUserId(), createdDday, user.getNickname(),
user.getUserLevel().getName(),
user.getFcmIsAllowed(),
savedAmountOfUser,
Expand Down

0 comments on commit b0c8fcf

Please sign in to comment.