-
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
Feat/챌린지 개별 정보 api 개발#256
- Loading branch information
Showing
7 changed files
with
336 additions
and
1 deletion.
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
22 changes: 22 additions & 0 deletions
22
src/main/java/com/habitpay/habitpay/domain/challenge/dto/ChallengeDatesResponse.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,22 @@ | ||
package com.habitpay.habitpay.domain.challenge.dto; | ||
|
||
import com.habitpay.habitpay.domain.challenge.domain.Challenge; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.time.ZonedDateTime; | ||
|
||
@Getter | ||
@Builder | ||
public class ChallengeDatesResponse { | ||
|
||
private ZonedDateTime startDate; | ||
private ZonedDateTime endDate; | ||
|
||
public static ChallengeDatesResponse from(Challenge challenge) { | ||
return ChallengeDatesResponse.builder() | ||
.startDate(challenge.getStartDate()) | ||
.endDate(challenge.getEndDate()) | ||
.build(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/habitpay/habitpay/domain/challenge/dto/ChallengeFeePerAbsenceResponse.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,18 @@ | ||
package com.habitpay.habitpay.domain.challenge.dto; | ||
|
||
import com.habitpay.habitpay.domain.challenge.domain.Challenge; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class ChallengeFeePerAbsenceResponse { | ||
|
||
private int feePerAbsence; | ||
|
||
public static ChallengeFeePerAbsenceResponse from(Challenge challenge) { | ||
return ChallengeFeePerAbsenceResponse.builder() | ||
.feePerAbsence(challenge.getFeePerAbsence()) | ||
.build(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...n/java/com/habitpay/habitpay/domain/challenge/dto/ChallengeParticipatingDaysResponse.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,38 @@ | ||
package com.habitpay.habitpay.domain.challenge.dto; | ||
|
||
import com.habitpay.habitpay.domain.challenge.domain.Challenge; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.time.DayOfWeek; | ||
import java.time.format.TextStyle; | ||
import java.util.EnumSet; | ||
import java.util.Locale; | ||
|
||
@Getter | ||
@Builder | ||
public class ChallengeParticipatingDaysResponse { | ||
|
||
private String[] participatingDays; | ||
|
||
public static ChallengeParticipatingDaysResponse from(Challenge challenge) { | ||
return ChallengeParticipatingDaysResponse.builder() | ||
.participatingDays(extractDaysFromBits(challenge.getParticipatingDays())) | ||
.build(); | ||
} | ||
|
||
public static String[] extractDaysFromBits(int participatingDays) { | ||
EnumSet<DayOfWeek> daysOfParticipatingDays = EnumSet.noneOf(DayOfWeek.class); | ||
|
||
for (int bit = 0; bit <= 6; bit += 1) { | ||
int todayBitPosition = 6 - bit; | ||
if ((participatingDays & (1 << todayBitPosition)) != 0) { | ||
daysOfParticipatingDays.add(DayOfWeek.of(bit + 1)); | ||
} | ||
} | ||
|
||
return daysOfParticipatingDays.stream() | ||
.map(day -> day.getDisplayName(TextStyle.SHORT, Locale.KOREAN)) | ||
.toArray(String[]::new); | ||
} | ||
} |
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