feat: add invoice-config-items management functionality
This commit is contained in:
170
sqlc_gen/invoice_config_item.sql.go
Normal file
170
sqlc_gen/invoice_config_item.sql.go
Normal file
@@ -0,0 +1,170 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.30.0
|
||||
// source: invoice_config_item.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const createInvoiceConfigItem = `-- name: CreateInvoiceConfigItem :one
|
||||
INSERT INTO invoice_config_items (invoice_config_id,component_id,required_quantity, allow_alternative,priority_order, note, metadata)
|
||||
VALUES (
|
||||
$1,
|
||||
$2,
|
||||
$3,
|
||||
$4,
|
||||
$5,
|
||||
$6,
|
||||
$7
|
||||
)
|
||||
RETURNING id, invoice_config_id, component_id, required_quantity, allow_alternative, priority_order, note, metadata
|
||||
`
|
||||
|
||||
type CreateInvoiceConfigItemParams struct {
|
||||
InvoiceConfigID int64 `db:"invoice_config_id" json:"invoiceConfigId"`
|
||||
ComponentID int64 `db:"component_id" json:"componentId"`
|
||||
RequiredQuantity int32 `db:"required_quantity" json:"requiredQuantity"`
|
||||
AllowAlternative bool `db:"allow_alternative" json:"allowAlternative"`
|
||||
PriorityOrder int32 `db:"priority_order" json:"priorityOrder"`
|
||||
Note pgtype.Text `db:"note" json:"note"`
|
||||
Metadata []byte `db:"metadata" json:"metadata"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateInvoiceConfigItem(ctx context.Context, arg CreateInvoiceConfigItemParams) (InvoiceConfigItem, error) {
|
||||
row := q.db.QueryRow(ctx, createInvoiceConfigItem,
|
||||
arg.InvoiceConfigID,
|
||||
arg.ComponentID,
|
||||
arg.RequiredQuantity,
|
||||
arg.AllowAlternative,
|
||||
arg.PriorityOrder,
|
||||
arg.Note,
|
||||
arg.Metadata,
|
||||
)
|
||||
var i InvoiceConfigItem
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.InvoiceConfigID,
|
||||
&i.ComponentID,
|
||||
&i.RequiredQuantity,
|
||||
&i.AllowAlternative,
|
||||
&i.PriorityOrder,
|
||||
&i.Note,
|
||||
&i.Metadata,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteInvoiceConfigItem = `-- name: DeleteInvoiceConfigItem :execrows
|
||||
DELETE FROM invoice_config_items
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteInvoiceConfigItem(ctx context.Context, id int64) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, deleteInvoiceConfigItem, id)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
const getInvoiceConfigItemByID = `-- name: GetInvoiceConfigItemByID :one
|
||||
SELECT id, invoice_config_id, component_id, required_quantity, allow_alternative, priority_order, note, metadata FROM invoice_config_items
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetInvoiceConfigItemByID(ctx context.Context, id int64) (InvoiceConfigItem, error) {
|
||||
row := q.db.QueryRow(ctx, getInvoiceConfigItemByID, id)
|
||||
var i InvoiceConfigItem
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.InvoiceConfigID,
|
||||
&i.ComponentID,
|
||||
&i.RequiredQuantity,
|
||||
&i.AllowAlternative,
|
||||
&i.PriorityOrder,
|
||||
&i.Note,
|
||||
&i.Metadata,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listInvoiceConfigItems = `-- name: ListInvoiceConfigItems :many
|
||||
SELECT id, invoice_config_id, component_id, required_quantity, allow_alternative, priority_order, note, metadata FROM invoice_config_items
|
||||
`
|
||||
|
||||
func (q *Queries) ListInvoiceConfigItems(ctx context.Context) ([]InvoiceConfigItem, error) {
|
||||
rows, err := q.db.Query(ctx, listInvoiceConfigItems)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []InvoiceConfigItem
|
||||
for rows.Next() {
|
||||
var i InvoiceConfigItem
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.InvoiceConfigID,
|
||||
&i.ComponentID,
|
||||
&i.RequiredQuantity,
|
||||
&i.AllowAlternative,
|
||||
&i.PriorityOrder,
|
||||
&i.Note,
|
||||
&i.Metadata,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const updateInvoiceConfigItem = `-- name: UpdateInvoiceConfigItem :one
|
||||
UPDATE invoice_config_items
|
||||
SET required_quantity = coalesce($1, required_quantity),
|
||||
allow_alternative = coalesce($2, allow_alternative),
|
||||
priority_order = coalesce($3, priority_order),
|
||||
note = coalesce($4, note),
|
||||
metadata = coalesce($5, metadata)
|
||||
WHERE id = $6
|
||||
RETURNING id, invoice_config_id, component_id, required_quantity, allow_alternative, priority_order, note, metadata
|
||||
`
|
||||
|
||||
type UpdateInvoiceConfigItemParams struct {
|
||||
RequiredQuantity int32 `db:"required_quantity" json:"requiredQuantity"`
|
||||
AllowAlternative bool `db:"allow_alternative" json:"allowAlternative"`
|
||||
PriorityOrder int32 `db:"priority_order" json:"priorityOrder"`
|
||||
Note pgtype.Text `db:"note" json:"note"`
|
||||
Metadata []byte `db:"metadata" json:"metadata"`
|
||||
ID int64 `db:"id" json:"id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateInvoiceConfigItem(ctx context.Context, arg UpdateInvoiceConfigItemParams) (InvoiceConfigItem, error) {
|
||||
row := q.db.QueryRow(ctx, updateInvoiceConfigItem,
|
||||
arg.RequiredQuantity,
|
||||
arg.AllowAlternative,
|
||||
arg.PriorityOrder,
|
||||
arg.Note,
|
||||
arg.Metadata,
|
||||
arg.ID,
|
||||
)
|
||||
var i InvoiceConfigItem
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.InvoiceConfigID,
|
||||
&i.ComponentID,
|
||||
&i.RequiredQuantity,
|
||||
&i.AllowAlternative,
|
||||
&i.PriorityOrder,
|
||||
&i.Note,
|
||||
&i.Metadata,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -21,6 +21,7 @@ type Querier interface {
|
||||
CreateComponentType(ctx context.Context, arg CreateComponentTypeParams) (ComponentType, error)
|
||||
CreateContainer(ctx context.Context, arg CreateContainerParams) (Container, error)
|
||||
CreateInvoiceConfig(ctx context.Context, arg CreateInvoiceConfigParams) (InvoiceConfig, error)
|
||||
CreateInvoiceConfigItem(ctx context.Context, arg CreateInvoiceConfigItemParams) (InvoiceConfigItem, error)
|
||||
CreateRole(ctx context.Context, arg CreateRoleParams) (Role, error)
|
||||
CreateRoom(ctx context.Context, arg CreateRoomParams) (Room, error)
|
||||
CreateShelve(ctx context.Context, arg CreateShelveParams) (Shelf, error)
|
||||
@@ -33,6 +34,7 @@ type Querier interface {
|
||||
DeleteComponentType(ctx context.Context, id int64) (int64, error)
|
||||
DeleteContainer(ctx context.Context, id int64) (int64, error)
|
||||
DeleteInvoiceConfig(ctx context.Context, id int64) (int64, error)
|
||||
DeleteInvoiceConfigItem(ctx context.Context, id int64) (int64, error)
|
||||
DeleteRole(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DeleteRoom(ctx context.Context, id int64) (int64, error)
|
||||
DeleteShelve(ctx context.Context, id int64) (int64, error)
|
||||
@@ -46,6 +48,7 @@ type Querier interface {
|
||||
GetComponentTypeByID(ctx context.Context, id int64) (ComponentType, error)
|
||||
GetContainerByID(ctx context.Context, id int64) (Container, error)
|
||||
GetInvoiceConfigByID(ctx context.Context, id int64) (InvoiceConfig, error)
|
||||
GetInvoiceConfigItemByID(ctx context.Context, id int64) (InvoiceConfigItem, error)
|
||||
GetRoleByID(ctx context.Context, id uuid.UUID) (Role, error)
|
||||
GetRoomByID(ctx context.Context, id int64) (Room, error)
|
||||
GetShelveByID(ctx context.Context, id int64) (Shelf, error)
|
||||
@@ -62,6 +65,7 @@ type Querier interface {
|
||||
ListComponentTypes(ctx context.Context) ([]ComponentType, error)
|
||||
ListComponents(ctx context.Context) ([]Component, error)
|
||||
ListContainers(ctx context.Context) ([]Container, error)
|
||||
ListInvoiceConfigItems(ctx context.Context) ([]InvoiceConfigItem, error)
|
||||
ListInvoiceConfigs(ctx context.Context) ([]InvoiceConfig, error)
|
||||
ListRoles(ctx context.Context) ([]Role, error)
|
||||
ListRooms(ctx context.Context) ([]Room, error)
|
||||
@@ -78,6 +82,7 @@ type Querier interface {
|
||||
UpdateComponentType(ctx context.Context, arg UpdateComponentTypeParams) (ComponentType, error)
|
||||
UpdateContainer(ctx context.Context, arg UpdateContainerParams) (Container, error)
|
||||
UpdateInvoiceConfig(ctx context.Context, arg UpdateInvoiceConfigParams) (InvoiceConfig, error)
|
||||
UpdateInvoiceConfigItem(ctx context.Context, arg UpdateInvoiceConfigItemParams) (InvoiceConfigItem, error)
|
||||
UpdateRole(ctx context.Context, arg UpdateRoleParams) (Role, error)
|
||||
UpdateRoom(ctx context.Context, arg UpdateRoomParams) (Room, error)
|
||||
UpdateShelve(ctx context.Context, arg UpdateShelveParams) (Shelf, error)
|
||||
|
||||
Reference in New Issue
Block a user