Added some structs to represent a few database tables.
This commit is contained in:
@@ -5,10 +5,36 @@ import (
|
|||||||
_ "encoding/json"
|
_ "encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
_ "github.com/lib/pq"
|
_ "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() {
|
func main() {
|
||||||
http.HandleFunc("/data", get)
|
http.HandleFunc("/data", get)
|
||||||
err := http.ListenAndServe(":8080", nil)
|
err := http.ListenAndServe(":8080", nil)
|
||||||
|
|||||||
Reference in New Issue
Block a user