43 lines
1.3 KiB
Go
43 lines
1.3 KiB
Go
package repository
|
|
|
|
import (
|
|
"database/sql"
|
|
"go-udemy-web-1/internal/models"
|
|
"time"
|
|
|
|
"github.com/jackc/pgx/v5"
|
|
)
|
|
|
|
type DatabaseRepo interface {
|
|
AllUsers() bool
|
|
|
|
InsertReservation(res models.Reservation) (int, error)
|
|
InsertRoomRestriction(res models.RoomRestriction) error
|
|
SearchAvailabilityByDatesByRoomID(start, end time.Time, roomID int) (bool, error)
|
|
SearchAvailabilityForAllRooms(start, end time.Time) ([]models.Room, error)
|
|
GetRoomById(id int) (models.Room, error)
|
|
GetUserByID(id int) (models.User, error)
|
|
UpdateUser(u models.User) error
|
|
Authenticate(email, testPassword string) (int, string, error)
|
|
AllReservations() ([]models.Reservation, error)
|
|
AllNewReservations() ([]models.Reservation, error)
|
|
GetReservationByID(id int) (models.Reservation, error)
|
|
UpdateReservation(r models.Reservation) error
|
|
DeleteReservation(id int) error
|
|
UpdateProcessedForReservation(id, processed int) error
|
|
AllRooms() ([]models.Room, error)
|
|
GetRestrictionsForRoomByDate(roomId int, start, end time.Time) ([]models.RoomRestriction, error)
|
|
InsertBlockForRoom(id int, startDate time.Time) error
|
|
DeleteBlockByID(id int) error
|
|
}
|
|
|
|
// DB holds the database connection pool
|
|
type DB struct {
|
|
SQL *sql.DB
|
|
PG *pgx.Conn
|
|
}
|
|
|
|
type DatabaseDriverRepo interface {
|
|
ConnectSQL(dsn string) (*DB, error)
|
|
}
|