refactors data access layer to use pop ORM for eager loading, adds book titles rented to renters in response body

This commit is contained in:
David Lick
2020-05-31 00:40:32 -04:00
parent a06b4d70ab
commit 28e52a4e08
29 changed files with 732 additions and 287 deletions
+6 -5
View File
@@ -10,9 +10,10 @@ import (
"time"
"github.com/davidlick/bookish/bookish-server/cmd/http"
"github.com/davidlick/bookish/bookish-server/inventory"
"github.com/davidlick/bookish/bookish-server/mysql"
"github.com/davidlick/bookish/bookish-server/rental"
"github.com/davidlick/bookish/bookish-server/renter"
_ "github.com/go-sql-driver/mysql"
"github.com/sirupsen/logrus"
)
@@ -43,7 +44,7 @@ func init() {
func main() {
// Connect to application database and create store.
appDSN := fmt.Sprintf("%s:%s@tcp(%s:%s)/bookish?parseTime=True&loc=Local",
appDSN := fmt.Sprintf("mysql://%s:%s@tcp(%s:%s)/bookish?parseTime=true&loc=local&multiStatements=true",
cfg.DBUser,
cfg.DBPass,
cfg.DBHost,
@@ -56,15 +57,15 @@ func main() {
// Build domain services.
renterService := renter.NewService(appDB)
inventoryService := inventory.NewService(appDB)
rentalService := rental.NewService(appDB)
// Initialize server.
server := http.Server{
Port: cfg.APIPort,
BooksHost: cfg.BooksHost,
Logger: logger,
Renter: renterService,
Inventory: inventoryService,
Renters: renterService,
Rentals: rentalService,
}
// Create channels to listen for OS signals.