From 6e4f7044e88a67816f01a80a81533147d3731306 Mon Sep 17 00:00:00 2001 From: Garritt McCune Date: Thu, 2 Sep 2021 22:02:16 -0500 Subject: [PATCH] Added some structs to represent a few database tables. --- cmd/inv/main.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/cmd/inv/main.go b/cmd/inv/main.go index 13bb367..5f01ed5 100644 --- a/cmd/inv/main.go +++ b/cmd/inv/main.go @@ -5,10 +5,36 @@ import ( _ "encoding/json" "fmt" "net/http" + "time" _ "github.com/lib/pq" ) +type Item struct { + Id int32 `json:"id"` + Name int32 `json:"name"` + ValueCents int32 `json:"valueCents"` + PurchaseCostCents int32 `json:"purchasedCostCents"` + Aquired time.Time `json:"aquired"` + Description string `json:"description"` + Notes string `json:"notes"` + SoldForCents int32 `json:"soldForCents"` + SoldTo string `json:"soldTo"` + Category Category `json:"category"` + Subcategory Subcategory `json:"subcategory"` +} + +type Category struct { + Id int32 `json:"id"` + Name string `json:"name"` +} + +type Subcategory struct { + Id int32 `json:"id"` + Name string `json:"name"` + CategoryId int32 `json:"categoryId"` +} + func main() { http.HandleFunc("/data", get) err := http.ListenAndServe(":8080", nil)