add customer name, service info, second pickup location, and structured address fields to deliveries
This commit is contained in:
@@ -12,19 +12,32 @@ import (
|
||||
)
|
||||
|
||||
const createDelivery = `-- name: CreateDelivery :one
|
||||
INSERT INTO deliveries (date, pickup_location, product_name, address, phone, additional_phone, has_elevator, comment)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
RETURNING id, date, pickup_location, product_name, address, phone, additional_phone, has_elevator, comment, status, created_at, updated_at
|
||||
INSERT INTO deliveries (
|
||||
date, pickup_location, pickup_location_2, product_name, product_name_2,
|
||||
customer_name, address, street, house, apartment, entrance, floor,
|
||||
phone, additional_phone, has_elevator, service_info, comment
|
||||
)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
|
||||
RETURNING id, date, pickup_location, product_name, address, phone, additional_phone, has_elevator, comment, status, created_at, updated_at, customer_name, service_info, pickup_location_2, product_name_2, street, house, apartment, entrance, floor
|
||||
`
|
||||
|
||||
type CreateDeliveryParams struct {
|
||||
Date pgtype.Date `db:"date" json:"date"`
|
||||
PickupLocation string `db:"pickup_location" json:"pickup_location"`
|
||||
PickupLocation2 pgtype.Text `db:"pickup_location_2" json:"pickup_location_2"`
|
||||
ProductName string `db:"product_name" json:"product_name"`
|
||||
ProductName2 pgtype.Text `db:"product_name_2" json:"product_name_2"`
|
||||
CustomerName string `db:"customer_name" json:"customer_name"`
|
||||
Address string `db:"address" json:"address"`
|
||||
Street string `db:"street" json:"street"`
|
||||
House string `db:"house" json:"house"`
|
||||
Apartment pgtype.Text `db:"apartment" json:"apartment"`
|
||||
Entrance pgtype.Text `db:"entrance" json:"entrance"`
|
||||
Floor pgtype.Text `db:"floor" json:"floor"`
|
||||
Phone string `db:"phone" json:"phone"`
|
||||
AdditionalPhone pgtype.Text `db:"additional_phone" json:"additional_phone"`
|
||||
HasElevator bool `db:"has_elevator" json:"has_elevator"`
|
||||
ServiceInfo pgtype.Text `db:"service_info" json:"service_info"`
|
||||
Comment pgtype.Text `db:"comment" json:"comment"`
|
||||
}
|
||||
|
||||
@@ -32,11 +45,20 @@ func (q *Queries) CreateDelivery(ctx context.Context, arg CreateDeliveryParams)
|
||||
row := q.db.QueryRow(ctx, createDelivery,
|
||||
arg.Date,
|
||||
arg.PickupLocation,
|
||||
arg.PickupLocation2,
|
||||
arg.ProductName,
|
||||
arg.ProductName2,
|
||||
arg.CustomerName,
|
||||
arg.Address,
|
||||
arg.Street,
|
||||
arg.House,
|
||||
arg.Apartment,
|
||||
arg.Entrance,
|
||||
arg.Floor,
|
||||
arg.Phone,
|
||||
arg.AdditionalPhone,
|
||||
arg.HasElevator,
|
||||
arg.ServiceInfo,
|
||||
arg.Comment,
|
||||
)
|
||||
var i Delivery
|
||||
@@ -53,6 +75,15 @@ func (q *Queries) CreateDelivery(ctx context.Context, arg CreateDeliveryParams)
|
||||
&i.Status,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.CustomerName,
|
||||
&i.ServiceInfo,
|
||||
&i.PickupLocation2,
|
||||
&i.ProductName2,
|
||||
&i.Street,
|
||||
&i.House,
|
||||
&i.Apartment,
|
||||
&i.Entrance,
|
||||
&i.Floor,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -90,7 +121,7 @@ func (q *Queries) DeleteDelivery(ctx context.Context, id pgtype.UUID) error {
|
||||
}
|
||||
|
||||
const getDeliveriesByDate = `-- name: GetDeliveriesByDate :many
|
||||
SELECT id, date, pickup_location, product_name, address, phone, additional_phone, has_elevator, comment, status, created_at, updated_at FROM deliveries WHERE date = $1
|
||||
SELECT id, date, pickup_location, product_name, address, phone, additional_phone, has_elevator, comment, status, created_at, updated_at, customer_name, service_info, pickup_location_2, product_name_2, street, house, apartment, entrance, floor FROM deliveries WHERE date = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetDeliveriesByDate(ctx context.Context, date pgtype.Date) ([]Delivery, error) {
|
||||
@@ -115,6 +146,15 @@ func (q *Queries) GetDeliveriesByDate(ctx context.Context, date pgtype.Date) ([]
|
||||
&i.Status,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.CustomerName,
|
||||
&i.ServiceInfo,
|
||||
&i.PickupLocation2,
|
||||
&i.ProductName2,
|
||||
&i.Street,
|
||||
&i.House,
|
||||
&i.Apartment,
|
||||
&i.Entrance,
|
||||
&i.Floor,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -127,7 +167,7 @@ func (q *Queries) GetDeliveriesByDate(ctx context.Context, date pgtype.Date) ([]
|
||||
}
|
||||
|
||||
const getDeliveryByID = `-- name: GetDeliveryByID :one
|
||||
SELECT id, date, pickup_location, product_name, address, phone, additional_phone, has_elevator, comment, status, created_at, updated_at FROM deliveries WHERE id = $1
|
||||
SELECT id, date, pickup_location, product_name, address, phone, additional_phone, has_elevator, comment, status, created_at, updated_at, customer_name, service_info, pickup_location_2, product_name_2, street, house, apartment, entrance, floor FROM deliveries WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetDeliveryByID(ctx context.Context, id pgtype.UUID) (Delivery, error) {
|
||||
@@ -146,6 +186,15 @@ func (q *Queries) GetDeliveryByID(ctx context.Context, id pgtype.UUID) (Delivery
|
||||
&i.Status,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.CustomerName,
|
||||
&i.ServiceInfo,
|
||||
&i.PickupLocation2,
|
||||
&i.ProductName2,
|
||||
&i.Street,
|
||||
&i.House,
|
||||
&i.Apartment,
|
||||
&i.Entrance,
|
||||
&i.Floor,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -198,17 +247,45 @@ func (q *Queries) GetUserByUsername(ctx context.Context, username string) (User,
|
||||
}
|
||||
|
||||
const updateDelivery = `-- name: UpdateDelivery :exec
|
||||
UPDATE deliveries SET date = $1, pickup_location = $2, product_name = $3, address = $4, phone = $5, additional_phone = $6, has_elevator = $7, comment = $8, updated_at = NOW() WHERE id = $9
|
||||
UPDATE deliveries SET
|
||||
date = $1,
|
||||
pickup_location = $2,
|
||||
pickup_location_2 = $3,
|
||||
product_name = $4,
|
||||
product_name_2 = $5,
|
||||
customer_name = $6,
|
||||
address = $7,
|
||||
street = $8,
|
||||
house = $9,
|
||||
apartment = $10,
|
||||
entrance = $11,
|
||||
floor = $12,
|
||||
phone = $13,
|
||||
additional_phone = $14,
|
||||
has_elevator = $15,
|
||||
service_info = $16,
|
||||
comment = $17,
|
||||
updated_at = NOW()
|
||||
WHERE id = $18
|
||||
`
|
||||
|
||||
type UpdateDeliveryParams struct {
|
||||
Date pgtype.Date `db:"date" json:"date"`
|
||||
PickupLocation string `db:"pickup_location" json:"pickup_location"`
|
||||
PickupLocation2 pgtype.Text `db:"pickup_location_2" json:"pickup_location_2"`
|
||||
ProductName string `db:"product_name" json:"product_name"`
|
||||
ProductName2 pgtype.Text `db:"product_name_2" json:"product_name_2"`
|
||||
CustomerName string `db:"customer_name" json:"customer_name"`
|
||||
Address string `db:"address" json:"address"`
|
||||
Street string `db:"street" json:"street"`
|
||||
House string `db:"house" json:"house"`
|
||||
Apartment pgtype.Text `db:"apartment" json:"apartment"`
|
||||
Entrance pgtype.Text `db:"entrance" json:"entrance"`
|
||||
Floor pgtype.Text `db:"floor" json:"floor"`
|
||||
Phone string `db:"phone" json:"phone"`
|
||||
AdditionalPhone pgtype.Text `db:"additional_phone" json:"additional_phone"`
|
||||
HasElevator bool `db:"has_elevator" json:"has_elevator"`
|
||||
ServiceInfo pgtype.Text `db:"service_info" json:"service_info"`
|
||||
Comment pgtype.Text `db:"comment" json:"comment"`
|
||||
ID pgtype.UUID `db:"id" json:"id"`
|
||||
}
|
||||
@@ -217,11 +294,20 @@ func (q *Queries) UpdateDelivery(ctx context.Context, arg UpdateDeliveryParams)
|
||||
_, err := q.db.Exec(ctx, updateDelivery,
|
||||
arg.Date,
|
||||
arg.PickupLocation,
|
||||
arg.PickupLocation2,
|
||||
arg.ProductName,
|
||||
arg.ProductName2,
|
||||
arg.CustomerName,
|
||||
arg.Address,
|
||||
arg.Street,
|
||||
arg.House,
|
||||
arg.Apartment,
|
||||
arg.Entrance,
|
||||
arg.Floor,
|
||||
arg.Phone,
|
||||
arg.AdditionalPhone,
|
||||
arg.HasElevator,
|
||||
arg.ServiceInfo,
|
||||
arg.Comment,
|
||||
arg.ID,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user