mirror of
https://github.com/foomo/shop.git
synced 2025-10-16 12:35:39 +00:00
renamed history package to version to avoid confusion with event history
This commit is contained in:
parent
50da96e9ba
commit
6fd8a2751b
@ -5,7 +5,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/foomo/shop/crypto"
|
"github.com/foomo/shop/crypto"
|
||||||
"github.com/foomo/shop/history"
|
"github.com/foomo/shop/version"
|
||||||
"gopkg.in/mgo.v2/bson"
|
"gopkg.in/mgo.v2/bson"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ import (
|
|||||||
|
|
||||||
type CustomerCredentials struct {
|
type CustomerCredentials struct {
|
||||||
BsonId bson.ObjectId `bson:"_id,omitempty"`
|
BsonId bson.ObjectId `bson:"_id,omitempty"`
|
||||||
Version *history.Version
|
Version *version.Version
|
||||||
Email string // always stored lowercase
|
Email string // always stored lowercase
|
||||||
Crypto *crypto.Crypto
|
Crypto *crypto.Crypto
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ func CreateCustomerCredentials(email, password string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
credentials := &CustomerCredentials{
|
credentials := &CustomerCredentials{
|
||||||
Version: history.NewVersion(),
|
Version: version.NewVersion(),
|
||||||
Email: lc(email),
|
Email: lc(email),
|
||||||
Crypto: crypto,
|
Crypto: crypto,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,9 +9,9 @@ import (
|
|||||||
"gopkg.in/mgo.v2/bson"
|
"gopkg.in/mgo.v2/bson"
|
||||||
|
|
||||||
"github.com/foomo/shop/event_log"
|
"github.com/foomo/shop/event_log"
|
||||||
"github.com/foomo/shop/history"
|
|
||||||
"github.com/foomo/shop/unique"
|
"github.com/foomo/shop/unique"
|
||||||
"github.com/foomo/shop/utils"
|
"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!
|
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
|
unlinkDB bool // if true, changes to Customer are not stored in database
|
||||||
Flags *Flags
|
Flags *Flags
|
||||||
Version *history.Version
|
Version *version.Version
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
LastModifiedAt time.Time
|
LastModifiedAt time.Time
|
||||||
Email string // unique, used as Login Credential
|
Email string // unique, used as Login Credential
|
||||||
@ -128,7 +128,7 @@ func NewCustomer(email, password string, customProvider CustomerCustomProvider)
|
|||||||
|
|
||||||
customer := &Customer{
|
customer := &Customer{
|
||||||
Flags: &Flags{},
|
Flags: &Flags{},
|
||||||
Version: history.NewVersion(),
|
Version: version.NewVersion(),
|
||||||
Id: unique.GetNewID(),
|
Id: unique.GetNewID(),
|
||||||
Email: lc(email),
|
Email: lc(email),
|
||||||
CreatedAt: utils.TimeNow(),
|
CreatedAt: utils.TimeNow(),
|
||||||
@ -229,7 +229,7 @@ func (customer *Customer) RemoveAddress(id string) {
|
|||||||
// ~ PUBLIC METHODS
|
// ~ 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.
|
// If openInBrowser, the result is automatically displayed in the default browser.
|
||||||
func DiffTwoLatestCustomerVersions(customerId string, customProvider CustomerCustomProvider, openInBrowser bool) (string, error) {
|
func DiffTwoLatestCustomerVersions(customerId string, customProvider CustomerCustomProvider, openInBrowser bool) (string, error) {
|
||||||
version, err := GetCurrentVersionOfCustomerFromHistory(customerId)
|
version, err := GetCurrentVersionOfCustomerFromHistory(customerId)
|
||||||
@ -254,7 +254,7 @@ func DiffCustomerVersions(customerId string, versionA int, versionB int, customP
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
html, err := history.DiffVersions(customerVersionA, customerVersionB)
|
html, err := version.DiffVersions(customerVersionA, customerVersionB)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,8 +4,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/foomo/shop/history"
|
|
||||||
"github.com/foomo/shop/utils"
|
"github.com/foomo/shop/utils"
|
||||||
|
"github.com/foomo/shop/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
@ -16,7 +16,7 @@ func (customer *Customer) GetID() string {
|
|||||||
return customer.Id
|
return customer.Id
|
||||||
}
|
}
|
||||||
|
|
||||||
func (customer *Customer) GetVersion() *history.Version {
|
func (customer *Customer) GetVersion() *version.Version {
|
||||||
return customer.Version
|
return customer.Version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,8 @@ import (
|
|||||||
|
|
||||||
"github.com/foomo/shop/configuration"
|
"github.com/foomo/shop/configuration"
|
||||||
"github.com/foomo/shop/event_log"
|
"github.com/foomo/shop/event_log"
|
||||||
"github.com/foomo/shop/history"
|
|
||||||
"github.com/foomo/shop/persistence"
|
"github.com/foomo/shop/persistence"
|
||||||
|
"github.com/foomo/shop/version"
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
"gopkg.in/mgo.v2/bson"
|
"gopkg.in/mgo.v2/bson"
|
||||||
)
|
)
|
||||||
@ -238,7 +238,7 @@ func GetCustomerByEmail(email string, customProvider CustomerCustomProvider) (*C
|
|||||||
func GetCurrentCustomerByIdFromHistory(customerId string, customProvider CustomerCustomProvider) (*Customer, error) {
|
func GetCurrentCustomerByIdFromHistory(customerId string, customProvider CustomerCustomProvider) (*Customer, error) {
|
||||||
return findOneCustomer(&bson.M{"id": customerId}, nil, "-version.current", customProvider, true)
|
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)
|
customer, err := findOneCustomer(&bson.M{"id": customerId}, &bson.M{"version": 1}, "-version.current", nil, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@ -13,12 +13,12 @@ import (
|
|||||||
"gopkg.in/mgo.v2/bson"
|
"gopkg.in/mgo.v2/bson"
|
||||||
|
|
||||||
"github.com/foomo/shop/event_log"
|
"github.com/foomo/shop/event_log"
|
||||||
"github.com/foomo/shop/history"
|
|
||||||
"github.com/foomo/shop/payment"
|
"github.com/foomo/shop/payment"
|
||||||
"github.com/foomo/shop/shipping"
|
"github.com/foomo/shop/shipping"
|
||||||
"github.com/foomo/shop/state"
|
"github.com/foomo/shop/state"
|
||||||
"github.com/foomo/shop/unique"
|
"github.com/foomo/shop/unique"
|
||||||
"github.com/foomo/shop/utils"
|
"github.com/foomo/shop/utils"
|
||||||
|
"github.com/foomo/shop/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
@ -53,7 +53,7 @@ type OrderStatus string
|
|||||||
type Order struct {
|
type Order struct {
|
||||||
BsonId bson.ObjectId `bson:"_id,omitempty"`
|
BsonId bson.ObjectId `bson:"_id,omitempty"`
|
||||||
Id string // automatically generated unique id
|
Id string // automatically generated unique id
|
||||||
Version *history.Version
|
Version *version.Version
|
||||||
unlinkDB bool // if true, changes to Customer are not stored in database
|
unlinkDB bool // if true, changes to Customer are not stored in database
|
||||||
Flags *Flags
|
Flags *Flags
|
||||||
State *state.State
|
State *state.State
|
||||||
@ -136,7 +136,7 @@ func NewOrderWithCustomId(customProvider OrderCustomProvider, orderIdFunc func()
|
|||||||
State: stateMachine.GetInitialState(),
|
State: stateMachine.GetInitialState(),
|
||||||
Flags: &Flags{},
|
Flags: &Flags{},
|
||||||
Id: orderId,
|
Id: orderId,
|
||||||
Version: history.NewVersion(),
|
Version: version.NewVersion(),
|
||||||
CreatedAt: utils.TimeNow(),
|
CreatedAt: utils.TimeNow(),
|
||||||
LastModifiedAt: utils.TimeNow(),
|
LastModifiedAt: utils.TimeNow(),
|
||||||
OrderType: OrderTypeOrder,
|
OrderType: OrderTypeOrder,
|
||||||
@ -272,7 +272,7 @@ func (p *Position) GetAmount() float64 {
|
|||||||
// ~ PUBLIC METHODS
|
// ~ 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.
|
// If openInBrowser, the result is automatically displayed in the default browser.
|
||||||
func DiffTwoLatestOrderVersions(orderId string, customProvider OrderCustomProvider, openInBrowser bool) (string, error) {
|
func DiffTwoLatestOrderVersions(orderId string, customProvider OrderCustomProvider, openInBrowser bool) (string, error) {
|
||||||
version, err := GetCurrentVersionOfOrderFromHistory(orderId)
|
version, err := GetCurrentVersionOfOrderFromHistory(orderId)
|
||||||
@ -297,7 +297,7 @@ func DiffOrderVersions(orderId string, versionA int, versionB int, customProvide
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
html, err := history.DiffVersions(orderVersionA, orderVersionB)
|
html, err := version.DiffVersions(orderVersionA, orderVersionB)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,11 +5,11 @@ import (
|
|||||||
|
|
||||||
"github.com/foomo/shop/customer"
|
"github.com/foomo/shop/customer"
|
||||||
"github.com/foomo/shop/event_log"
|
"github.com/foomo/shop/event_log"
|
||||||
"github.com/foomo/shop/history"
|
|
||||||
"github.com/foomo/shop/payment"
|
"github.com/foomo/shop/payment"
|
||||||
"github.com/foomo/shop/shipping"
|
"github.com/foomo/shop/shipping"
|
||||||
"github.com/foomo/shop/state"
|
"github.com/foomo/shop/state"
|
||||||
"github.com/foomo/shop/utils"
|
"github.com/foomo/shop/utils"
|
||||||
|
"github.com/foomo/shop/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
@ -20,7 +20,7 @@ func (order *Order) GetID() string {
|
|||||||
return order.Id
|
return order.Id
|
||||||
}
|
}
|
||||||
|
|
||||||
func (order *Order) GetVersion() *history.Version {
|
func (order *Order) GetVersion() *version.Version {
|
||||||
return order.Version
|
return order.Version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,8 +7,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/foomo/shop/event_log"
|
"github.com/foomo/shop/event_log"
|
||||||
"github.com/foomo/shop/history"
|
|
||||||
"github.com/foomo/shop/persistence"
|
"github.com/foomo/shop/persistence"
|
||||||
|
"github.com/foomo/shop/version"
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
|
|
||||||
"github.com/foomo/shop/configuration"
|
"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) {
|
func GetCurrentOrderByIdFromHistory(orderId string, customProvider OrderCustomProvider) (*Order, error) {
|
||||||
return findOneOrder(&bson.M{"id": orderId}, nil, "-version.current", customProvider, true)
|
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)
|
order, err := findOneOrder(&bson.M{"id": orderId}, &bson.M{"version": 1}, "-version.current", nil, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package history
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
Loading…
Reference in New Issue
Block a user