Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] 피드생성시 레벨업 달성여부 bool 값 responseBody에 담게끔 수정 #235

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
public class CreateFeedResponseDto {
private Long feedId;
private LocalDateTime createdAt;
private Boolean levelUpgraded;

public static CreateFeedResponseDto of(Long feedId, LocalDateTime createdAt){
return new CreateFeedResponseDto(feedId, createdAt);
public static CreateFeedResponseDto of(Long feedId, LocalDateTime createdAt, Boolean levelUpgraded){
return new CreateFeedResponseDto(feedId, createdAt, levelUpgraded);
}

}
10 changes: 8 additions & 2 deletions src/main/java/org/winey/server/service/FeedService.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,17 @@ public CreateFeedResponseDto createFeed(CreateFeedRequestDto request, Long userI
// 5. 레벨업을 체크한다.
UserLevel newUserLevel = UserLevel.calculateUserLevel(presentUser.getSavedAmount(), presentUser.getSavedCount());

// 레벨업 달성 여부 담는 Bool 값
Boolean levelUpgraded = false;

if (presentUser.getUserLevel() != newUserLevel) {
// 4-1. 레벨업한다.
presentUser.updateUserLevel(newUserLevel);

// 4-2. 레벨업 알림을 생성한다.
// 4-2. 레벨업 달성 여부를 true로 수정
levelUpgraded = true;

// 4-3. 레벨업 알림을 생성한다.
switch (newUserLevel) {
case KNIGHT:
notificationBuilderInFeed(NotiType.RANKUPTO2, presentUser);
Expand All @@ -94,7 +100,7 @@ public CreateFeedResponseDto createFeed(CreateFeedRequestDto request, Long userI
}
}

return CreateFeedResponseDto.of(feed.getFeedId(), feed.getCreatedAt());
return CreateFeedResponseDto.of(feed.getFeedId(), feed.getCreatedAt(), levelUpgraded);
}

@Transactional
Expand Down
Loading