mirror of
https://github.com/rjNemo/go-microservices-tuto
synced 2026-06-06 02:16:46 +00:00
23 lines
570 B
Go
23 lines
570 B
Go
package models
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io"
|
|
)
|
|
|
|
// Product defines the structure of a product
|
|
type Product struct {
|
|
ID int `json:"id"` //TODO: use uuid
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
Price float32 `json:"price"` // TODO: use int
|
|
SKU string `json:"sku"`
|
|
CreatedOn string `json:"-"`
|
|
UpdatedOn string `json:"-"`
|
|
DeletedOn string `json:"-"`
|
|
}
|
|
|
|
// FromJSON read JSON data to create a new product
|
|
func (p *Product) FromJSON(r io.Reader) error {
|
|
return json.NewDecoder(r).Decode(p)
|
|
}
|