mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-11-17 03:50:05 -05:00
Aaron Lindsay
a357d38eee
This adds 'shadow' types used only by the store/db internal package whch handle converting these types to their DB-equivalent values. This change should allow reports to be generated significantly faster since it allows a large portion of the computation to be shifted to the database engines.
42 lines
833 B
Go
42 lines
833 B
Go
package models
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
type Price struct {
|
|
PriceId int64
|
|
SecurityId int64
|
|
CurrencyId int64
|
|
Date time.Time
|
|
Value Amount // price of Security in Currency units
|
|
RemoteId string // unique ID from source, for detecting duplicates
|
|
}
|
|
|
|
type PriceList struct {
|
|
Prices *[]*Price `json:"prices"`
|
|
}
|
|
|
|
func (p *Price) Read(json_str string) error {
|
|
dec := json.NewDecoder(strings.NewReader(json_str))
|
|
return dec.Decode(p)
|
|
}
|
|
|
|
func (p *Price) Write(w http.ResponseWriter) error {
|
|
enc := json.NewEncoder(w)
|
|
return enc.Encode(p)
|
|
}
|
|
|
|
func (pl *PriceList) Read(json_str string) error {
|
|
dec := json.NewDecoder(strings.NewReader(json_str))
|
|
return dec.Decode(pl)
|
|
}
|
|
|
|
func (pl *PriceList) Write(w http.ResponseWriter) error {
|
|
enc := json.NewEncoder(w)
|
|
return enc.Encode(pl)
|
|
}
|