-
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
…olar-term-info-api 절기 조회 API 구현
- Loading branch information
Showing
8 changed files
with
139 additions
and
74 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
33 changes: 33 additions & 0 deletions
33
src/main/java/today/seasoning/seasoning/solarterm/dto/FindSolarTermInfoResponse.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,33 @@ | ||
package today.seasoning.seasoning.solarterm.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonInclude.Include; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import today.seasoning.seasoning.solarterm.domain.SolarTerm; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@JsonInclude(Include.NON_NULL) | ||
public class FindSolarTermInfoResponse { | ||
|
||
private final boolean recordable; | ||
private final SolarTermDto currentTerm; | ||
private final SolarTermDto nextTerm; | ||
private final SolarTermDto recordTerm; | ||
|
||
public static FindSolarTermInfoResponse build(SolarTerm currentSolarTerm, SolarTerm nextSolarTerm, SolarTerm recordSolarTerm, int recordPeriod) { | ||
boolean recordable = recordSolarTerm != null; | ||
SolarTermDto currentTerm = SolarTermDto.build(currentSolarTerm); | ||
SolarTermDto nextTerm = SolarTermDto.build(nextSolarTerm); | ||
|
||
SolarTermDto recordTerm = null; | ||
if(recordable) { | ||
recordTerm = new SolarTermDto( | ||
recordSolarTerm.getSequence(), | ||
recordSolarTerm.getDate().plusDays(recordPeriod)); | ||
} | ||
|
||
return new FindSolarTermInfoResponse(recordable, currentTerm, nextTerm, recordTerm); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/today/seasoning/seasoning/solarterm/dto/SolarTermDto.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 today.seasoning.seasoning.solarterm.dto; | ||
|
||
import java.time.LocalDate; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import today.seasoning.seasoning.solarterm.domain.SolarTerm; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public class SolarTermDto { | ||
|
||
private final int sequence; | ||
private final LocalDate date; | ||
|
||
public static SolarTermDto build(SolarTerm solarTerm) { | ||
return new SolarTermDto(solarTerm.getSequence(), solarTerm.getDate()); | ||
} | ||
} |
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