Skip to content

Commit

Permalink
Merge pull request #104 from Central-MakeUs/103-스탬프-관련-이슈들-수정
Browse files Browse the repository at this point in the history
Feat(#103): 스탬프 관련 이슈들 수정
  • Loading branch information
tmddus2 authored Aug 28, 2024
2 parents 9b53d18 + bbcdad6 commit 7aa6a64
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -60,6 +61,7 @@ public static List<GroupedFilterLogDto> groupByDate(List<FilterLogDto> filterLog
groupedFilters.add(groupedFilter);
}

Collections.sort(groupedFilters, (s1, s2) -> s1.getDate().compareTo(s2.getDate()));
return groupedFilters;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -61,6 +62,7 @@ public static List<GroupedStampDto> groupByDate(List<StampDto> stampDtos) {
groupedStamps.add(groupedStamp);
}

Collections.sort(groupedStamps, (s1, s2) -> s1.getDate().compareTo(s2.getDate()));
return groupedStamps;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,15 @@
public enum Membership {
BASIC,
PREMIUM,
PREMIUM_PLUS
PREMIUM_PLUS;

public static Membership checkMembership(int numOfReviews) {
if (numOfReviews >= 8) {
return PREMIUM_PLUS;
}
if (numOfReviews >= 4) {
return PREMIUM;
}
return BASIC;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,8 @@ public CreatedReviewDto writeReview(Long id, ReviewRequestDto request) {

private void upgradeMembership(User user) {
int numOfReviews = reviewRepository.countAllByUser(user);
if (numOfReviews == 16) {
user.upgradeToPremiumPlus();
userRepository.save(user);
} else if (numOfReviews == 8) {
user.upgradeToPremium();
userRepository.save(user);
}
user.updateMembership(numOfReviews);
userRepository.save(user);
}

public List<FeedDto> getFeeds(OS os, String sortedBy, Long userId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ public class User {
public void agreeToTerms() {
this.terms = true;
}
public void upgradeToPremium() {
this.membership = Membership.PREMIUM;
}
public void upgradeToPremiumPlus() {
this.membership = Membership.PREMIUM_PLUS;

public void updateMembership(int numOfReviews) {
this.membership = Membership.checkMembership(numOfReviews);
}

public void updateProfile(UserInfoRequestDto userInfo) {
this.profile = userInfo.profile();
this.username = userInfo.name();
Expand Down

0 comments on commit 7aa6a64

Please sign in to comment.