-
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.
Feature/#86 시연을 위한 시간 모킹
- Loading branch information
Showing
7 changed files
with
85 additions
and
3 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
13 changes: 12 additions & 1 deletion
13
src/main/java/unithon/uniletter/message/repository/MessageRepository.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package unithon.uniletter.time; | ||
|
||
import java.time.LocalDate; | ||
|
||
public record TimeRequest(LocalDate localDate) { | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/unithon/uniletter/time/controller/TimeController.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,21 @@ | ||
package unithon.uniletter.time.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import unithon.uniletter.time.TimeRequest; | ||
import unithon.uniletter.time.service.TimeService; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class TimeController { | ||
|
||
private final TimeService timeService; | ||
|
||
@PostMapping("/time") | ||
public ResponseEntity<Void> setServerTime(final TimeRequest timeRequest) { | ||
timeService.setServerTime(timeRequest.localDate()); | ||
return ResponseEntity.ok().build(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/unithon/uniletter/time/service/TimeGenerator.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,23 @@ | ||
package unithon.uniletter.time.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.LocalDate; | ||
import java.util.Optional; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class TimeGenerator { | ||
|
||
private LocalDate localDate; | ||
|
||
public LocalDate generate() { | ||
return Optional.ofNullable(localDate) | ||
.orElseGet(LocalDate::now); | ||
} | ||
|
||
public void setLocalDate(final LocalDate localDate) { | ||
this.localDate = localDate; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/unithon/uniletter/time/service/TimeService.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,17 @@ | ||
package unithon.uniletter.time.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.time.LocalDate; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class TimeService { | ||
|
||
private final TimeGenerator timeGenerator; | ||
|
||
public void setServerTime(final LocalDate localDate) { | ||
timeGenerator.setLocalDate(localDate); | ||
} | ||
} |