-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Issue/#41
- Loading branch information
Showing
18 changed files
with
200 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...p/src/main/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/DayCountType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.haedal.zzansuni.domain.challengegroup.userchallenge; | ||
|
||
import java.time.LocalDate; | ||
|
||
public interface DayCountType { | ||
LocalDate getDate(); | ||
Integer getCount(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 71 additions & 19 deletions
90
zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/user/UserModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,75 @@ | ||
package org.haedal.zzansuni.domain.user; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Builder | ||
public record UserModel( | ||
Long id, | ||
String email, | ||
String nickname, | ||
String profileImageUrl, | ||
Integer exp | ||
) { | ||
public static UserModel from(User user) { | ||
return UserModel.builder() | ||
.id(user.getId()) | ||
.email(user.getEmail()) | ||
.nickname(user.getNickname()) | ||
.profileImageUrl(user.getProfileImageUrl()) | ||
.exp(user.getExp()) | ||
.build(); | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
|
||
public class UserModel{ | ||
@Builder | ||
public record Main( | ||
Long id, | ||
String email, | ||
String nickname, | ||
String profileImageUrl, | ||
Integer exp | ||
) { | ||
public static Main from(User user) { | ||
return Main.builder() | ||
.id(user.getId()) | ||
.email(user.getEmail()) | ||
.nickname(user.getNickname()) | ||
.profileImageUrl(user.getProfileImageUrl()) | ||
.exp(user.getExp()) | ||
.build(); | ||
} | ||
} | ||
} | ||
|
||
@Builder | ||
public record Strick( | ||
List<DayCount> dayCounts | ||
) { | ||
/** 여기서 count 0인걸 포함하는 기능을 쓰는게 맞는지 */ | ||
public static Strick from(Map<LocalDate, Integer> strickCounts, LocalDate startDate, LocalDate endDate) { | ||
List<DayCount> resultList = startDate.datesUntil(endDate.plusDays(1)) | ||
// 날짜가 존재하면 map(date)로 count를 가져오고, 없으면 0을 저장한다. | ||
.map(date -> new DayCount(date, strickCounts.getOrDefault(date, 0))) | ||
.collect(Collectors.toList()); | ||
return new Strick(resultList); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
if (dayCounts == null) { | ||
sb.append("null"); | ||
} else { | ||
for (int i = 0; i < dayCounts.size(); i++) { | ||
sb.append(dayCounts.get(i).toString()); | ||
if (i < dayCounts.size() - 1) | ||
sb.append("\n"); | ||
} | ||
} | ||
return sb.toString(); | ||
} | ||
|
||
} | ||
@Builder | ||
public record DayCount( | ||
LocalDate date, | ||
Integer count | ||
) { | ||
|
||
@Override | ||
public String toString() { | ||
return "DayCount{" + | ||
"date=" + date + | ||
", count=" + count + '}'; | ||
} | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.