diff --git a/customer/credentials.go b/customer/credentials.go index fd60e34..1859cfa 100644 --- a/customer/credentials.go +++ b/customer/credentials.go @@ -5,7 +5,7 @@ import ( "strings" "github.com/foomo/shop/crypto" - "github.com/foomo/shop/history" + "github.com/foomo/shop/version" "gopkg.in/mgo.v2/bson" ) @@ -15,7 +15,7 @@ import ( type CustomerCredentials struct { BsonId bson.ObjectId `bson:"_id,omitempty"` - Version *history.Version + Version *version.Version Email string // always stored lowercase Crypto *crypto.Crypto } @@ -49,7 +49,7 @@ func CreateCustomerCredentials(email, password string) error { return err } credentials := &CustomerCredentials{ - Version: history.NewVersion(), + Version: version.NewVersion(), Email: lc(email), Crypto: crypto, } diff --git a/customer/customer.go b/customer/customer.go index bd073a7..4cd45c3 100644 --- a/customer/customer.go +++ b/customer/customer.go @@ -9,9 +9,9 @@ import ( "gopkg.in/mgo.v2/bson" "github.com/foomo/shop/event_log" - "github.com/foomo/shop/history" "github.com/foomo/shop/unique" "github.com/foomo/shop/utils" + "github.com/foomo/shop/version" ) //------------------------------------------------------------------ @@ -52,7 +52,7 @@ type Customer struct { Id string // Email is used as LoginID, but can change. This is never changes! unlinkDB bool // if true, changes to Customer are not stored in database Flags *Flags - Version *history.Version + Version *version.Version CreatedAt time.Time LastModifiedAt time.Time Email string // unique, used as Login Credential @@ -128,7 +128,7 @@ func NewCustomer(email, password string, customProvider CustomerCustomProvider) customer := &Customer{ Flags: &Flags{}, - Version: history.NewVersion(), + Version: version.NewVersion(), Id: unique.GetNewID(), Email: lc(email), CreatedAt: utils.TimeNow(), @@ -229,7 +229,7 @@ func (customer *Customer) RemoveAddress(id string) { // ~ PUBLIC METHODS //------------------------------------------------------------------ -// DiffTwoLatestCustomerVersions compares the two latest Versions of Customer found in history. +// DiffTwoLatestCustomerVersions compares the two latest Versions of Customer found in version. // If openInBrowser, the result is automatically displayed in the default browser. func DiffTwoLatestCustomerVersions(customerId string, customProvider CustomerCustomProvider, openInBrowser bool) (string, error) { version, err := GetCurrentVersionOfCustomerFromHistory(customerId) @@ -254,7 +254,7 @@ func DiffCustomerVersions(customerId string, versionA int, versionB int, customP return "", err } - html, err := history.DiffVersions(customerVersionA, customerVersionB) + html, err := version.DiffVersions(customerVersionA, customerVersionB) if err != nil { return "", err } diff --git a/customer/customer_get_set.go b/customer/customer_get_set.go index a575de6..f1be6e1 100644 --- a/customer/customer_get_set.go +++ b/customer/customer_get_set.go @@ -4,8 +4,8 @@ import ( "errors" "time" - "github.com/foomo/shop/history" "github.com/foomo/shop/utils" + "github.com/foomo/shop/version" ) //------------------------------------------------------------------ @@ -16,7 +16,7 @@ func (customer *Customer) GetID() string { return customer.Id } -func (customer *Customer) GetVersion() *history.Version { +func (customer *Customer) GetVersion() *version.Version { return customer.Version } diff --git a/customer/persistor.go b/customer/persistor.go index 2549b44..5b6f678 100644 --- a/customer/persistor.go +++ b/customer/persistor.go @@ -8,8 +8,8 @@ import ( "github.com/foomo/shop/configuration" "github.com/foomo/shop/event_log" - "github.com/foomo/shop/history" "github.com/foomo/shop/persistence" + "github.com/foomo/shop/version" "github.com/mitchellh/mapstructure" "gopkg.in/mgo.v2/bson" ) @@ -238,7 +238,7 @@ func GetCustomerByEmail(email string, customProvider CustomerCustomProvider) (*C func GetCurrentCustomerByIdFromHistory(customerId string, customProvider CustomerCustomProvider) (*Customer, error) { return findOneCustomer(&bson.M{"id": customerId}, nil, "-version.current", customProvider, true) } -func GetCurrentVersionOfCustomerFromHistory(customerId string) (*history.Version, error) { +func GetCurrentVersionOfCustomerFromHistory(customerId string) (*version.Version, error) { customer, err := findOneCustomer(&bson.M{"id": customerId}, &bson.M{"version": 1}, "-version.current", nil, true) if err != nil { return nil, err diff --git a/order/order.go b/order/order.go index 3ac0e01..89726fb 100644 --- a/order/order.go +++ b/order/order.go @@ -13,12 +13,12 @@ import ( "gopkg.in/mgo.v2/bson" "github.com/foomo/shop/event_log" - "github.com/foomo/shop/history" "github.com/foomo/shop/payment" "github.com/foomo/shop/shipping" "github.com/foomo/shop/state" "github.com/foomo/shop/unique" "github.com/foomo/shop/utils" + "github.com/foomo/shop/version" ) //------------------------------------------------------------------ @@ -53,7 +53,7 @@ type OrderStatus string type Order struct { BsonId bson.ObjectId `bson:"_id,omitempty"` Id string // automatically generated unique id - Version *history.Version + Version *version.Version unlinkDB bool // if true, changes to Customer are not stored in database Flags *Flags State *state.State @@ -136,7 +136,7 @@ func NewOrderWithCustomId(customProvider OrderCustomProvider, orderIdFunc func() State: stateMachine.GetInitialState(), Flags: &Flags{}, Id: orderId, - Version: history.NewVersion(), + Version: version.NewVersion(), CreatedAt: utils.TimeNow(), LastModifiedAt: utils.TimeNow(), OrderType: OrderTypeOrder, @@ -272,7 +272,7 @@ func (p *Position) GetAmount() float64 { // ~ PUBLIC METHODS //------------------------------------------------------------------ -// DiffTwoLatestOrderVersions compares the two latest Versions of Order found in history. +// DiffTwoLatestOrderVersions compares the two latest Versions of Order found in version. // If openInBrowser, the result is automatically displayed in the default browser. func DiffTwoLatestOrderVersions(orderId string, customProvider OrderCustomProvider, openInBrowser bool) (string, error) { version, err := GetCurrentVersionOfOrderFromHistory(orderId) @@ -297,7 +297,7 @@ func DiffOrderVersions(orderId string, versionA int, versionB int, customProvide return "", err } - html, err := history.DiffVersions(orderVersionA, orderVersionB) + html, err := version.DiffVersions(orderVersionA, orderVersionB) if err != nil { return "", err } diff --git a/order/order_get_set.go b/order/order_get_set.go index 029350b..ffacc2b 100644 --- a/order/order_get_set.go +++ b/order/order_get_set.go @@ -5,11 +5,11 @@ import ( "github.com/foomo/shop/customer" "github.com/foomo/shop/event_log" - "github.com/foomo/shop/history" "github.com/foomo/shop/payment" "github.com/foomo/shop/shipping" "github.com/foomo/shop/state" "github.com/foomo/shop/utils" + "github.com/foomo/shop/version" ) //------------------------------------------------------------------ @@ -20,7 +20,7 @@ func (order *Order) GetID() string { return order.Id } -func (order *Order) GetVersion() *history.Version { +func (order *Order) GetVersion() *version.Version { return order.Version } diff --git a/order/persistor.go b/order/persistor.go index c8ef1c8..c8a3a79 100644 --- a/order/persistor.go +++ b/order/persistor.go @@ -7,8 +7,8 @@ import ( "strconv" "github.com/foomo/shop/event_log" - "github.com/foomo/shop/history" "github.com/foomo/shop/persistence" + "github.com/foomo/shop/version" "github.com/mitchellh/mapstructure" "github.com/foomo/shop/configuration" @@ -199,7 +199,7 @@ func GetOrderById(id string, customProvider OrderCustomProvider) (*Order, error) func GetCurrentOrderByIdFromHistory(orderId string, customProvider OrderCustomProvider) (*Order, error) { return findOneOrder(&bson.M{"id": orderId}, nil, "-version.current", customProvider, true) } -func GetCurrentVersionOfOrderFromHistory(orderId string) (*history.Version, error) { +func GetCurrentVersionOfOrderFromHistory(orderId string) (*version.Version, error) { order, err := findOneOrder(&bson.M{"id": orderId}, &bson.M{"version": 1}, "-version.current", nil, true) if err != nil { return nil, err diff --git a/history/history.go b/version/version.go similarity index 99% rename from history/history.go rename to version/version.go index ad7f076..3471fca 100644 --- a/history/history.go +++ b/version/version.go @@ -1,4 +1,4 @@ -package history +package version import ( "encoding/json"