fixed some login and booking bugs
This commit is contained in:
@@ -12,29 +12,33 @@ import (
|
||||
)
|
||||
|
||||
const createBooking = `-- name: CreateBooking :one
|
||||
INSERT INTO bookings (user_id, service_id, event_date, address, notes, status)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
RETURNING id, user_id, service_id, event_date, address, notes, created_at, status
|
||||
INSERT INTO bookings (user_id, service_id, event_date, address, notes, status, service_option, event_type)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
RETURNING id, user_id, service_id, event_date, address, notes, created_at, status, service_option, event_type
|
||||
`
|
||||
|
||||
type CreateBookingParams struct {
|
||||
UserID sql.NullInt64 `json:"user_id"`
|
||||
ServiceID sql.NullInt64 `json:"service_id"`
|
||||
EventDate time.Time `json:"event_date"`
|
||||
Address sql.NullString `json:"address"`
|
||||
Notes sql.NullString `json:"notes"`
|
||||
Status sql.NullString `json:"status"`
|
||||
UserID sql.NullInt64 `json:"user_id"`
|
||||
ServiceID sql.NullInt64 `json:"service_id"`
|
||||
EventDate time.Time `json:"event_date"`
|
||||
Address sql.NullString `json:"address"`
|
||||
Notes sql.NullString `json:"notes"`
|
||||
Status sql.NullString `json:"status"`
|
||||
ServiceOption sql.NullString `json:"service_option"`
|
||||
EventType sql.NullString `json:"event_type"`
|
||||
}
|
||||
|
||||
type CreateBookingRow struct {
|
||||
ID int64 `json:"id"`
|
||||
UserID sql.NullInt64 `json:"user_id"`
|
||||
ServiceID sql.NullInt64 `json:"service_id"`
|
||||
EventDate time.Time `json:"event_date"`
|
||||
Address sql.NullString `json:"address"`
|
||||
Notes sql.NullString `json:"notes"`
|
||||
CreatedAt sql.NullTime `json:"created_at"`
|
||||
Status sql.NullString `json:"status"`
|
||||
ID int64 `json:"id"`
|
||||
UserID sql.NullInt64 `json:"user_id"`
|
||||
ServiceID sql.NullInt64 `json:"service_id"`
|
||||
EventDate time.Time `json:"event_date"`
|
||||
Address sql.NullString `json:"address"`
|
||||
Notes sql.NullString `json:"notes"`
|
||||
CreatedAt sql.NullTime `json:"created_at"`
|
||||
Status sql.NullString `json:"status"`
|
||||
ServiceOption sql.NullString `json:"service_option"`
|
||||
EventType sql.NullString `json:"event_type"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateBooking(ctx context.Context, arg CreateBookingParams) (CreateBookingRow, error) {
|
||||
@@ -45,6 +49,8 @@ func (q *Queries) CreateBooking(ctx context.Context, arg CreateBookingParams) (C
|
||||
arg.Address,
|
||||
arg.Notes,
|
||||
arg.Status,
|
||||
arg.ServiceOption,
|
||||
arg.EventType,
|
||||
)
|
||||
var i CreateBookingRow
|
||||
err := row.Scan(
|
||||
@@ -56,25 +62,29 @@ func (q *Queries) CreateBooking(ctx context.Context, arg CreateBookingParams) (C
|
||||
&i.Notes,
|
||||
&i.CreatedAt,
|
||||
&i.Status,
|
||||
&i.ServiceOption,
|
||||
&i.EventType,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getBooking = `-- name: GetBooking :one
|
||||
SELECT id, user_id, service_id, event_date, address, notes, created_at, status
|
||||
SELECT id, user_id, service_id, event_date, address, notes, created_at, status, service_option, event_type
|
||||
FROM bookings
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
type GetBookingRow struct {
|
||||
ID int64 `json:"id"`
|
||||
UserID sql.NullInt64 `json:"user_id"`
|
||||
ServiceID sql.NullInt64 `json:"service_id"`
|
||||
EventDate time.Time `json:"event_date"`
|
||||
Address sql.NullString `json:"address"`
|
||||
Notes sql.NullString `json:"notes"`
|
||||
CreatedAt sql.NullTime `json:"created_at"`
|
||||
Status sql.NullString `json:"status"`
|
||||
ID int64 `json:"id"`
|
||||
UserID sql.NullInt64 `json:"user_id"`
|
||||
ServiceID sql.NullInt64 `json:"service_id"`
|
||||
EventDate time.Time `json:"event_date"`
|
||||
Address sql.NullString `json:"address"`
|
||||
Notes sql.NullString `json:"notes"`
|
||||
CreatedAt sql.NullTime `json:"created_at"`
|
||||
Status sql.NullString `json:"status"`
|
||||
ServiceOption sql.NullString `json:"service_option"`
|
||||
EventType sql.NullString `json:"event_type"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetBooking(ctx context.Context, id int64) (GetBookingRow, error) {
|
||||
@@ -89,26 +99,30 @@ func (q *Queries) GetBooking(ctx context.Context, id int64) (GetBookingRow, erro
|
||||
&i.Notes,
|
||||
&i.CreatedAt,
|
||||
&i.Status,
|
||||
&i.ServiceOption,
|
||||
&i.EventType,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listBookingsByUser = `-- name: ListBookingsByUser :many
|
||||
SELECT id, user_id, service_id, event_date, address, notes, created_at, status
|
||||
SELECT id, user_id, service_id, event_date, address, notes, created_at, status, service_option, event_type
|
||||
FROM bookings
|
||||
WHERE user_id = $1
|
||||
ORDER BY event_date DESC
|
||||
`
|
||||
|
||||
type ListBookingsByUserRow struct {
|
||||
ID int64 `json:"id"`
|
||||
UserID sql.NullInt64 `json:"user_id"`
|
||||
ServiceID sql.NullInt64 `json:"service_id"`
|
||||
EventDate time.Time `json:"event_date"`
|
||||
Address sql.NullString `json:"address"`
|
||||
Notes sql.NullString `json:"notes"`
|
||||
CreatedAt sql.NullTime `json:"created_at"`
|
||||
Status sql.NullString `json:"status"`
|
||||
ID int64 `json:"id"`
|
||||
UserID sql.NullInt64 `json:"user_id"`
|
||||
ServiceID sql.NullInt64 `json:"service_id"`
|
||||
EventDate time.Time `json:"event_date"`
|
||||
Address sql.NullString `json:"address"`
|
||||
Notes sql.NullString `json:"notes"`
|
||||
CreatedAt sql.NullTime `json:"created_at"`
|
||||
Status sql.NullString `json:"status"`
|
||||
ServiceOption sql.NullString `json:"service_option"`
|
||||
EventType sql.NullString `json:"event_type"`
|
||||
}
|
||||
|
||||
func (q *Queries) ListBookingsByUser(ctx context.Context, userID sql.NullInt64) ([]ListBookingsByUserRow, error) {
|
||||
@@ -129,6 +143,8 @@ func (q *Queries) ListBookingsByUser(ctx context.Context, userID sql.NullInt64)
|
||||
&i.Notes,
|
||||
&i.CreatedAt,
|
||||
&i.Status,
|
||||
&i.ServiceOption,
|
||||
&i.EventType,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -153,6 +169,8 @@ SELECT
|
||||
b.notes,
|
||||
b.created_at,
|
||||
b.status,
|
||||
b.service_option,
|
||||
b.event_type,
|
||||
s.name as service_name,
|
||||
s.description as service_description,
|
||||
s.price_cents as service_price_cents
|
||||
@@ -171,6 +189,8 @@ type ListBookingsWithServiceByUserRow struct {
|
||||
Notes sql.NullString `json:"notes"`
|
||||
CreatedAt sql.NullTime `json:"created_at"`
|
||||
Status sql.NullString `json:"status"`
|
||||
ServiceOption sql.NullString `json:"service_option"`
|
||||
EventType sql.NullString `json:"event_type"`
|
||||
ServiceName string `json:"service_name"`
|
||||
ServiceDescription sql.NullString `json:"service_description"`
|
||||
ServicePriceCents int32 `json:"service_price_cents"`
|
||||
@@ -194,6 +214,8 @@ func (q *Queries) ListBookingsWithServiceByUser(ctx context.Context, userID sql.
|
||||
&i.Notes,
|
||||
&i.CreatedAt,
|
||||
&i.Status,
|
||||
&i.ServiceOption,
|
||||
&i.EventType,
|
||||
&i.ServiceName,
|
||||
&i.ServiceDescription,
|
||||
&i.ServicePriceCents,
|
||||
|
||||
Reference in New Issue
Block a user