types

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	gorm.Model
	// Account has many postings, AccountID is the foreign key
	Postings   []Posting
	BusinessID string  `gorm:"type:varchar(24);not null;unique_index"`
	Balance    float64 `gorm:"not null;default:0"`
}

type AdminTag

type AdminTag struct {
	ID        primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"`
	CreatedAt time.Time          `json:"createdAt,omitempty" bson:"createdAt,omitempty"`
	UpdatedAt time.Time          `json:"updatedAt,omitempty" bson:"updatedAt,omitempty"`
	DeletedAt time.Time          `json:"deletedAt,omitempty" bson:"deletedAt,omitempty"`

	Name string `json:"name,omitempty" bson:"name,omitempty"`
}

AdminTag is the model representation of an admin tag in the data model.

type AdminUser

type AdminUser struct {
	ID        primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"`
	CreatedAt time.Time          `json:"createdAt,omitempty" bson:"createdAt,omitempty"`
	UpdatedAt time.Time          `json:"updatedAt,omitempty" bson:"updatedAt,omitempty"`
	DeletedAt time.Time          `json:"deletedAt,omitempty" bson:"deletedAt,omitempty"`

	Email    string   `json:"email,omitempty" bson:"email,omitempty"`
	Name     string   `json:"name,omitempty" bson:"name,omitempty"`
	Password string   `json:"password,omitempty" bson:"password,omitempty"`
	Roles    []string `json:"roles,omitempty" bson:"roles,omitempty"`

	CurrentLoginIP   string    `json:"currentLoginIP,omitempty" bson:"currentLoginIP,omitempty"`
	CurrentLoginDate time.Time `json:"currentLoginDate,omitempty" bson:"currentLoginDate,omitempty"`
	LastLoginIP      string    `json:"lastLoginIP,omitempty" bson:"lastLoginIP,omitempty"`
	LastLoginDate    time.Time `json:"lastLoginDate,omitempty" bson:"lastLoginDate,omitempty"`
}

AdminUser is the model representation of an admin user in the data model.

type BalanceLimit

type BalanceLimit struct {
	gorm.Model
	// `BalanceLimit` belongs to `Account`, `AccountID` is the foreign key
	Account   Account
	AccountID uint    `gorm:"not null;unique_index"`
	MaxNegBal float64 `gorm:"type:int;not null"`
	MaxPosBal float64 `gorm:"type:int;not null"`
}

type Business

type Business struct {
	ID        primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"`
	CreatedAt time.Time          `json:"createdAt,omitempty" bson:"createdAt,omitempty"`
	UpdatedAt time.Time          `json:"updatedAt,omitempty" bson:"updatedAt,omitempty"`
	DeletedAt time.Time          `json:"deletedAt,omitempty" bson:"deletedAt,omitempty"`

	BusinessName       string      `json:"businessName,omitempty" bson:"businessName,omitempty"`
	BusinessPhone      string      `json:"businessPhone,omitempty" bson:"businessPhone,omitempty"`
	IncType            string      `json:"incType,omitempty" bson:"incType,omitempty"`
	CompanyNumber      string      `json:"companyNumber,omitempty" bson:"companyNumber,omitempty"`
	Website            string      `json:"website,omitempty" bson:"website,omitempty"`
	Turnover           int         `json:"turnover,omitempty" bson:"turnover,omitempty"`
	Offers             []*TagField `json:"offers,omitempty" bson:"offers,omitempty"`
	Wants              []*TagField `json:"wants,omitempty" bson:"wants,omitempty"`
	Description        string      `json:"description,omitempty" bson:"description,omitempty"`
	LocationAddress    string      `json:"locationAddress,omitempty" bson:"locationAddress,omitempty"`
	LocationCity       string      `json:"locationCity,omitempty" bson:"locationCity,omitempty"`
	LocationRegion     string      `json:"locationRegion,omitempty" bson:"locationRegion,omitempty"`
	LocationPostalCode string      `json:"locationPostalCode,omitempty" bson:"locationPostalCode,omitempty"`
	LocationCountry    string      `json:"locationCountry,omitempty" bson:"locationCountry,omitempty"`
	Status             string      `json:"status,omitempty" bson:"status,omitempty"`
	AdminTags          []string    `json:"adminTags,omitempty" bson:"adminTags,omitempty"`
	// Timestamp when trading status applied
	MemberStartedAt time.Time `json:"memberStartedAt,omitempty" bson:"memberStartedAt,omitempty"`
}

Business is the model representation of a business in the data model.

type BusinessData

type BusinessData struct {
	ID                 primitive.ObjectID
	BusinessName       string
	IncType            string
	CompanyNumber      string
	BusinessPhone      string
	Website            string
	Turnover           int
	Offers             []*TagField
	Wants              []*TagField
	OffersAdded        []string
	OffersRemoved      []string
	WantsAdded         []string
	WantsRemoved       []string
	Description        string
	LocationAddress    string
	LocationCity       string
	LocationRegion     string
	LocationPostalCode string
	LocationCountry    string
	Status             string
	AdminTags          []string
}

type BusinessESRecord

type BusinessESRecord struct {
	BusinessID      string      `json:"businessID,omitempty"`
	BusinessName    string      `json:"businessName,omitempty"`
	Offers          []*TagField `json:"offers,omitempty"`
	Wants           []*TagField `json:"wants,omitempty"`
	LocationCity    string      `json:"locationCity,omitempty"`
	LocationCountry string      `json:"locationCountry,omitempty"`
	Status          string      `json:"status,omitempty"`
	AdminTags       []string    `json:"adminTags,omitempty"`
}

BusinessESRecord is the data that will store into the elastic search.

type FindAdminTagResult

type FindAdminTagResult struct {
	AdminTags       []*AdminTag
	NumberOfResults int
	TotalPages      int
}

type FindBusinessResult

type FindBusinessResult struct {
	Businesses      []*Business
	NumberOfResults int
	TotalPages      int
}

type FindTagResult

type FindTagResult struct {
	Tags            []*Tag
	NumberOfResults int
	TotalPages      int
}

type FindUserResult

type FindUserResult struct {
	Users           []*User
	NumberOfResults int
	TotalPages      int
}

type Journal

type Journal struct {
	gorm.Model
	// Journal has many postings, JournalID is the foreign key
	Postings []Posting

	TransactionID string `gorm:"type:varchar(27);not null;default:''"`

	InitiatedBy uint `gorm:"type:int;not null;default:0"`

	FromID           uint   `gorm:"type:int;not null;default:0"`
	FromEmail        string `gorm:"type:varchar(120);not null;default:''"`
	FromBusinessName string `gorm:"type:varchar(120);not null;default:''"`

	ToID           uint   `gorm:"type:int;not null;default:0"`
	ToEmail        string `gorm:"type:varchar(120);not null;default:''"`
	ToBusinessName string `gorm:"type:varchar(120);not null;default:''"`

	Amount      float64 `gorm:"not null;default:0"`
	Description string  `gorm:"type:varchar(510);not null;default:''"`
	Type        string  `gorm:"type:varchar(31);not null;default:'transfer'"`
	Status      string  `gorm:"type:varchar(31);not null;default:''"`

	CancellationReason string `gorm:"type:varchar(510);not null;default:''"`
}

type LoginInfo

type LoginInfo struct {
	CurrentLoginIP   string    `json:"currentLoginIP,omitempty" bson:"currentLoginIP,omitempty"`
	CurrentLoginDate time.Time `json:"currentLoginDate,omitempty" bson:"currentLoginDate,omitempty"`
	LastLoginIP      string    `json:"lastLoginIP,omitempty" bson:"lastLoginIP,omitempty"`
	LastLoginDate    time.Time `json:"lastLoginDate,omitempty" bson:"lastLoginDate,omitempty"`
}

LoginInfo is shared by user and admin user model.

type LostPassword

type LostPassword struct {
	ID        primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"`
	CreatedAt time.Time          `json:"createdAt,omitempty" bson:"createdAt,omitempty"`
	Email     string             `json:"email,omitempty" bson:"email,omitempty"`
	Token     string             `json:"token,omitempty" bson:"token,omitempty"`
	TokenUsed bool               `json:"tokenUsed,omitempty" bson:"tokenUsed,omitempty"`
}

LostPassword is the model representation of a lost password in the data model.

type MatchedTags

type MatchedTags struct {
	MatchedOffers map[string][]string
	MatchedWants  map[string][]string
}

type Posting

type Posting struct {
	gorm.Model
	AccountID uint    `gorm:"not null"`
	JournalID uint    `gorm:"not null"`
	Amount    float64 `gorm:"not null"`
}

type RegisterData

type RegisterData struct {
	User             *User
	Business         *BusinessData
	ConfirmPassword  string
	ConfirmEmail     string
	Terms            string
	RecaptchaSitekey string
}

type SearchCriteria

type SearchCriteria struct {
	TagType          string
	Tags             []*TagField
	CreatedOnOrAfter time.Time

	Statuses              []string // accepted", "pending", rejected", "tradingPending", "tradingAccepted", "tradingRejected"
	BusinessName          string
	LocationCountry       string
	LocationCity          string
	ShowUserFavoritesOnly bool
	FavoriteBusinesses    []primitive.ObjectID
	AdminTag              string
}

type Tag

type Tag struct {
	ID        primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"`
	CreatedAt time.Time          `json:"createdAt,omitempty" bson:"createdAt,omitempty"`
	UpdatedAt time.Time          `json:"updatedAt,omitempty" bson:"updatedAt,omitempty"`
	DeletedAt time.Time          `json:"deletedAt,omitempty" bson:"deletedAt,omitempty"`

	Name         string    `json:"name,omitempty" bson:"name,omitempty"`
	OfferAddedAt time.Time `json:"offerAddedAt,omitempty" bson:"offerAddedAt,omitempty"`
	WantAddedAt  time.Time `json:"wantAddedAt,omitempty" bson:"wantAddedAt,omitempty"`
}

Tag is the model representation of a tag in the data model.

type TagESRecord

type TagESRecord struct {
	TagID        string    `json:"tagID,omitempty"`
	Name         string    `json:"name,omitempty"`
	OfferAddedAt time.Time `json:"offerAddedAt,omitempty"`
	WantAddedAt  time.Time `json:"wantAddedAt,omitempty"`
}

type TagField

type TagField struct {
	Name      string    `json:"name,omitempty" bson:"name,omitempty"`
	CreatedAt time.Time `json:"createdAt,omitempty" bson:"createdAt,omitempty"`
}

type TradingRegisterData

type TradingRegisterData struct {
	// Business
	BusinessName       string
	IncType            string
	CompanyNumber      string
	BusinessPhone      string
	Website            string
	Turnover           int
	Description        string
	LocationAddress    string
	LocationCity       string
	LocationRegion     string
	LocationPostalCode string
	LocationCountry    string
	// User
	FirstName string
	LastName  string
	Telephone string
	// Terms
	Authorised string
	// Recaptcha
	RecaptchaSitekey string
}

func (*TradingRegisterData) Validate

func (t *TradingRegisterData) Validate() []string

type TradingUpdateData

type TradingUpdateData struct {
	// Business
	BusinessName       string
	IncType            string
	CompanyNumber      string
	BusinessPhone      string
	Website            string
	Turnover           int
	Description        string
	LocationAddress    string
	LocationCity       string
	LocationRegion     string
	LocationPostalCode string
	LocationCountry    string
	// User
	FirstName string
	LastName  string
	Telephone string
	// Recaptcha
	RecaptchaSitekey string
}

func (*TradingUpdateData) Validate

func (t *TradingUpdateData) Validate() []string

type Transaction

type Transaction struct {
	ID               uint // Journal ID
	TransactionID    string
	IsInitiator      bool
	InitiatedBy      uint
	FromID           uint
	FromEmail        string
	FromBusinessName string
	ToID             uint
	ToEmail          string
	ToBusinessName   string
	Amount           float64
	Description      string
	Status           string
	CreatedAt        time.Time
}

type UpdateAccountData

type UpdateAccountData struct {
	User            *User
	Business        *BusinessData
	Balance         *BalanceLimit
	CurrentPassword string
	ConfirmPassword string
}

type User

type User struct {
	ID        primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"`
	CreatedAt time.Time          `json:"createdAt,omitempty" bson:"createdAt,omitempty"`
	UpdatedAt time.Time          `json:"updatedAt,omitempty" bson:"updatedAt,omitempty"`
	DeletedAt time.Time          `json:"deletedAt,omitempty" bson:"deletedAt,omitempty"`

	FirstName string             `json:"firstName,omitempty" bson:"firstName,omitempty"`
	LastName  string             `json:"lastName,omitempty" bson:"lastName,omitempty"`
	Email     string             `json:"email,omitempty" bson:"email,omitempty"`
	Password  string             `json:"password,omitempty" bson:"password,omitempty"`
	Telephone string             `json:"telephone,omitempty" bson:"telephone,omitempty"`
	CompanyID primitive.ObjectID `json:"companyID,omitempty" bson:"companyID,omitempty"`

	CurrentLoginIP   string    `json:"currentLoginIP,omitempty" bson:"currentLoginIP,omitempty"`
	CurrentLoginDate time.Time `json:"currentLoginDate,omitempty" bson:"currentLoginDate,omitempty"`
	LastLoginIP      string    `json:"lastLoginIP,omitempty" bson:"lastLoginIP,omitempty"`
	LastLoginDate    time.Time `json:"lastLoginDate,omitempty" bson:"lastLoginDate,omitempty"`

	LoginAttempts     int       `json:"loginAttempts,omitempty" bson:"loginAttempts,omitempty"`
	LastLoginFailDate time.Time `json:"lastLoginFailDate,omitempty" bson:"lastLoginFailDate,omitempty"`

	ShowRecentMatchedTags    bool                 `json:"showRecentMatchedTags,omitempty" bson:"showRecentMatchedTags,omitempty"`
	FavoriteBusinesses       []primitive.ObjectID `json:"favoriteBusinesses,omitempty" bson:"favoriteBusinesses,omitempty"`
	DailyNotification        bool                 `json:"dailyNotification,omitempty" bson:"dailyNotification,omitempty"`
	LastNotificationSentDate time.Time            `json:"lastNotificationSentDate,omitempty" bson:"lastNotificationSentDate,omitempty"`
}

User is the model representation of an user in the data model.

type UserAction

type UserAction struct {
	ID        primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"`
	CreatedAt time.Time          `json:"createdAt,omitempty" bson:"createdAt,omitempty"`
	UpdatedAt time.Time          `json:"updatedAt,omitempty" bson:"updatedAt,omitempty"`
	DeletedAt time.Time          `json:"deletedAt,omitempty" bson:"deletedAt,omitempty"`

	UserID        primitive.ObjectID `json:"userID,omitempty" bson:"userID,omitempty"`
	Email         string             `json:"email,omitempty" bson:"email,omitempty"`
	Action        string             `json:"action,omitempty" bson:"action,omitempty"`
	ActionDetails string             `json:"actionDetails,omitempty" bson:"actionDetails,omitempty"`
	Category      string             `json:"category,omitempty" bson:"category,omitempty"`
}

UserAction is the model representation of an user action in the data model.

type UserActionSearchCriteria

type UserActionSearchCriteria struct {
	Email    string
	Category string
	DateFrom time.Time
	DateTo   time.Time
}

type UserESRecord

type UserESRecord struct {
	UserID    string `json:"userID"`
	FirstName string `json:"firstName,omitempty"`
	LastName  string `json:"lastName,omitempty"`
	Email     string `json:"email,omitempty"`
}

UserESRecord is the data that will store into the elastic search.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL