Update db function and add to web-back

This commit is contained in:
2024-08-07 11:56:53 +02:00
parent d32667acd1
commit 85cd4dfc1f
4 changed files with 27 additions and 13 deletions

View File

@ -69,8 +69,8 @@ type Transaction struct {
Amount int `json:"amount"`
Currency string `json:"currency"`
LastFour string `json:"last_four"`
BankReturnCode string `json:bank_return_code`
TransactionStatusID int `json:transaction_status_id`
BankReturnCode string `json:"bank_return_code"`
TransactionStatusID int `json:"transaction_status_id"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
}
@ -92,10 +92,22 @@ func (m *DBModel) GetWidget(id int) (Widget, error) {
var widget Widget
query := `SELECT id, name FROM widgets WHERE id = ?`
query := `SELECT id, name, description, inventory_level, price,
coalesce(image, ''),
created_at, updated_at
FROM widgets WHERE id = ?;`
row := m.DB.QueryRowContext(ctx, query, id)
err := row.Scan(&widget.ID, &widget.Name)
err := row.Scan(
&widget.ID,
&widget.Name,
&widget.Description,
&widget.InventoryLevel,
&widget.Price,
&widget.Image,
&widget.CreatedAt,
&widget.UpdatedAt,
)
if err != nil {
return widget, err
}