Skip to content

Commit c6c4094

Browse files
committed
refactor(TimeController, TimeRequest): 코드 리팩토링(new Time() -> toTime())
1 parent 14df9d0 commit c6c4094

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/main/java/roomescape/controller/TimeController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public Time mapRow(ResultSet rs, int rowNum) throws SQLException {
4444
@PostMapping("/times")
4545
public ResponseEntity<Time> createTimes(@RequestBody TimeRequest timeRequest) {
4646
String timeValue = timeRequest.getTime();
47-
Time time = new Time(timeValue);
47+
Time time = timeRequest.toTime();
4848

4949
String sql = "INSERT INTO time (time) VALUES (?)";
5050
KeyHolder keyHolder = new GeneratedKeyHolder();

src/main/java/roomescape/model/time/TimeRequest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.fasterxml.jackson.annotation.JsonProperty;
44

55
public class TimeRequest {
6+
67
@JsonProperty("time")
78
private String time;
89

@@ -16,4 +17,8 @@ public String getTime() {
1617
public void setTime(String time) {
1718
this.time = time;
1819
}
20+
21+
public Time toTime() {
22+
return new Time(this.time);
23+
}
1924
}

0 commit comments

Comments
 (0)