generated from PenaSide/GolangTemplate
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
type Account struct {
|
|
ID string `json:"id" bson:"_id,omitempty"`
|
|
UserID string `json:"userId" bson:"userId"`
|
|
Cart []string `json:"cart" bson:"cart"`
|
|
Wallet Wallet `json:"wallet" bson:"wallet"`
|
|
Name Name `json:"name" bson:"name"`
|
|
Status AccountStatus `json:"status" bson:"status"`
|
|
Deleted bool `json:"isDeleted" bson:"isDeleted"`
|
|
CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
|
|
UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"`
|
|
DeletedAt *time.Time `json:"deletedAt,omitempty" bson:"deletedAt,omitempty"`
|
|
}
|
|
|
|
func (receiver *Account) Sanitize() *Account {
|
|
now := time.Now()
|
|
|
|
receiver.ID = ""
|
|
receiver.Cart = []string{}
|
|
receiver.Wallet = Wallet{}
|
|
receiver.Name = Name{}
|
|
receiver.Status = DefaultAccountStatus
|
|
receiver.CreatedAt = now
|
|
receiver.UpdatedAt = now
|
|
receiver.DeletedAt = nil
|
|
receiver.Deleted = false
|
|
|
|
return receiver
|
|
}
|
|
|
|
type Name struct {
|
|
Middlename string `json:"middlename,omitempty"`
|
|
FirstName string `json:"firstname,omitempty"`
|
|
Orgname string `json:"orgname,omitempty"`
|
|
Secondname string `json:"secondname,omitempty"`
|
|
}
|
|
|
|
type SetAccountStatus struct {
|
|
Status AccountStatus `json:"status"`
|
|
}
|
|
|
|
type AccountStatus string
|
|
|
|
const (
|
|
AccountStatusNko AccountStatus = "nko"
|
|
AccountStatusNo AccountStatus = "no"
|
|
AccountStatusOrg AccountStatus = "org"
|
|
DefaultAccountStatus AccountStatus = AccountStatusNo
|
|
)
|