mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-12 13:46:51 +00:00
feat: add list booking api route
This commit is contained in:
parent
cb6677ca60
commit
84d341b616
2 changed files with 16 additions and 0 deletions
|
|
@ -52,6 +52,21 @@ func handleBookingListPage(bs *booking.Service, hc *config.Host) echo.HandlerFun
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleBookingList(bs *booking.Service, hc *config.Host) echo.HandlerFunc {
|
||||||
|
return func(c echo.Context) error {
|
||||||
|
search := c.FormValue("search")
|
||||||
|
|
||||||
|
var bookings []*booking.Line
|
||||||
|
if search != "" {
|
||||||
|
bookings = bs.Search(search)
|
||||||
|
} else {
|
||||||
|
bookings = bs.All()
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.JSON(http.StatusOK, bookings)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func handleBookingCreatePage(hc *config.Host) echo.HandlerFunc {
|
func handleBookingCreatePage(hc *config.Host) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
return renderTempl(c, http.StatusOK, view.NewBooking(hc.Platforms))
|
return renderTempl(c, http.StatusOK, view.NewBooking(hc.Platforms))
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ func (s Server) MountHandlers() {
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
api.POST("/sync", handleSync(s.bs))
|
api.POST("/sync", handleSync(s.bs))
|
||||||
|
api.GET("/bookings", handleBookingList(s.bs, s.hc))
|
||||||
|
|
||||||
private := s.Router.Group("")
|
private := s.Router.Group("")
|
||||||
private.Use(MakeAuthMiddleware(s.as))
|
private.Use(MakeAuthMiddleware(s.as))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue