Skip to content

Commit

Permalink
[Feat] 마이페이지 응답값 변경 (#247)
Browse files Browse the repository at this point in the history
* [Feat] 마이페이지 응답값 변경 (+가입일, -100일 절약 금액)

* [Feat] 마이페이지 응답값 가입일 -> 가입 디데이로 변경
  • Loading branch information
funnysunny08 authored May 13, 2024
1 parent 2067395 commit 5c0b1eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.winey.server.controller.response.user;

import org.winey.server.domain.user.UserLevel;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand All @@ -20,24 +18,23 @@ public class UserResponseDto {
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public static class UserData {
private Long userId;
private Long createdDday;
private String nickname;
private String userLevel;
private Boolean fcmIsAllowed;
private Long accumulatedAmount;
private Long accumulatedCount;
private Long amountSavedHundredDays;
private Long amountSavedTwoWeeks;
private Long amountSpentTwoWeeks;
private Long remainingAmount;
private Long remainingCount;
}


public static UserResponseDto of(Long userId, String nickname, String userLevel,
Boolean fcmIsAllowed, Long accumulatedAmount,Long accumulatedCount , Long amountSavedHundredDays, Long amountSavedTwoWeeks,
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, nickname, userLevel, fcmIsAllowed, accumulatedAmount, accumulatedCount,
amountSavedHundredDays, amountSavedTwoWeeks, amountSpentTwoWeeks,remainingAmount,remainingCount);
UserData userData = new UserData(userId, createdDday, nickname, userLevel, fcmIsAllowed, accumulatedAmount, accumulatedCount,
amountSavedTwoWeeks, amountSpentTwoWeeks,remainingAmount,remainingCount);
return new UserResponseDto(userData);
}
}
7 changes: 3 additions & 4 deletions 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,8 +31,7 @@ public UserResponseDto getUser(Long userId) {
Error.NOT_FOUND_USER_EXCEPTION.getMessage()));

LocalDateTime twoWeeksAgo = LocalDateTime.now().minusWeeks(2);
LocalDateTime hundredDaysAgo = LocalDateTime.now().minusDays(100);
Long amountSavedHundredDays = feedRepository.getSavedAmountForPeriod(user, hundredDaysAgo);
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 @@ -43,12 +43,11 @@ 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.getNickname(),
return UserResponseDto.of(user.getUserId(), createdDday, user.getNickname(),
user.getUserLevel().getName(),
user.getFcmIsAllowed(),
savedAmountOfUser,
savedCountOfUser,
amountSavedHundredDays == null ? 0L : amountSavedHundredDays,
amountSavedTwoWeeks == null ? 0L : amountSavedTwoWeeks,
amountSpentTwoWeeks == null ? 0L : amountSpentTwoWeeks,
remainingAmount < 0 ? 0L : remainingAmount,
Expand Down

0 comments on commit 5c0b1eb

Please sign in to comment.