Skip to content

Commit c631a3e

Browse files
authored
Merge branch 'jeonseohee9' into jeonseohee92
2 parents 3cdfd34 + 3ef700a commit c631a3e

File tree

5 files changed

+90
-1
lines changed

5 files changed

+90
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package roomescape.Controller;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.web.bind.annotation.GetMapping;
5+
6+
@Controller
7+
public class PageController {
8+
9+
@GetMapping("/")
10+
public String home() {
11+
return "home";
12+
}
13+
14+
@GetMapping("/reservation")
15+
public String reservationPage() {
16+
return "reservation";
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package roomescape.Controller;
2+
3+
import java.time.LocalDate;
4+
import java.time.LocalTime;
5+
import java.util.ArrayList;
6+
import java.util.List;
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.RestController;
9+
import roomescape.Domain.Reservation;
10+
11+
@RestController
12+
public class ReservationController {
13+
14+
private final List<Reservation> reservations = new ArrayList<>();
15+
16+
public ReservationController() {
17+
reservations.add(new Reservation(1, "브라운", LocalDate.parse("2023-01-01"), LocalTime.parse("10:00")));
18+
reservations.add(new Reservation(2, "브라운", LocalDate.parse("2023-01-02"), LocalTime.parse("10:00")));
19+
reservations.add(new Reservation(3, "브라운", LocalDate.parse("2023-01-03"), LocalTime.parse("10:00")));
20+
}
21+
22+
@GetMapping("/reservations")
23+
public List<Reservation> findAll() {
24+
return reservations;
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package roomescape.Domain;
2+
3+
import java.time.LocalDate;
4+
import java.time.LocalTime;
5+
6+
public class Reservation {
7+
8+
private final Integer id;
9+
private final String name;
10+
private final LocalDate date;
11+
private final LocalTime time;
12+
13+
public Reservation(Integer id, String name, LocalDate date, LocalTime time) {
14+
this.id = id;
15+
this.name = name;
16+
this.date = date;
17+
this.time = time;
18+
}
19+
20+
public Reservation() {
21+
this.id = null;
22+
this.name = null;
23+
this.date = null;
24+
this.time = null;
25+
}
26+
27+
public Integer getId() {
28+
return id;
29+
}
30+
31+
public String getName() {
32+
return name;
33+
}
34+
35+
public LocalDate getDate() {
36+
return date;
37+
}
38+
39+
public LocalTime getTime() {
40+
return time;
41+
}
42+
}

src/main/java/roomescape/service/ReservationService.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public ReservationService(ReservationDAO reservationDAO) {
1919
this.reservationDAO = reservationDAO;
2020
}
2121

22-
public Reservation add(Reservation reservation) {
22+
public Reservation add(Reservation reservation) {
2323
boolean isDuplicate = reservationDAO.findAll().stream().anyMatch(r ->
2424
r.getName().equals(reservation.getName()) &&
2525
r.getDate().equals(reservation.getDate()) &&
@@ -51,4 +51,6 @@ public void update(Reservation reservation) {
5151
}
5252
reservationDAO.updateReservation(reservation);
5353
}
54+
55+
5456
}

src/test/java/roomescape/MissionStepTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,6 @@ public class MissionStepTest {
129129
Integer count = jdbcTemplate.queryForObject("SELECT count(1) from reservation", Integer.class);
130130

131131
assertThat(reservations.size()).isEqualTo(count);
132+
132133
}
133134
}

0 commit comments

Comments
 (0)