types

package
v0.0.0-...-7f18cf7 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TagFieldToNames

func TagFieldToNames(tags []*TagField) []string

func TagToNames

func TagToNames(tags []*Tag) []string

Types

type Account

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

type AddToFavoriteReq

type AddToFavoriteReq struct {
	AddToEntityID    string `json:"addToEntityID"`
	FavoriteEntityID string `json:"favoriteEntityID"`
	Favorite         *bool  `json:"favorite"`
}

func NewAddToFavoriteReq

func NewAddToFavoriteReq(r *http.Request) (*AddToFavoriteReq, []error)

type AdminCreateCategoryReq

type AdminCreateCategoryReq struct {
	Name string `json:"name"`
}

func NewAdminCreateCategoryReq

func NewAdminCreateCategoryReq(r *http.Request) (*AdminCreateCategoryReq, []error)

type AdminCreateTagReq

type AdminCreateTagReq struct {
	Name string `json:"name"`
}

func NewAdminCreateTagReq

func NewAdminCreateTagReq(r *http.Request) (*AdminCreateTagReq, []error)

type AdminDeleteCategoryReq

type AdminDeleteCategoryReq struct {
	ID primitive.ObjectID `json:"name"`
}

func NewAdminDeleteCategoryReq

func NewAdminDeleteCategoryReq(r *http.Request) (*AdminDeleteCategoryReq, []error)

type AdminDeleteEntity

type AdminDeleteEntity struct {
	EntityID primitive.ObjectID
}

func NewAdminDeleteEntity

func NewAdminDeleteEntity(r *http.Request) (*AdminDeleteEntity, []error)

type AdminDeleteEntityRespond

type AdminDeleteEntityRespond struct {
	ID                                 string   `json:"id"`
	AccountNumber                      string   `json:"accountNumber"`
	Name                               string   `json:"name"`
	Email                              string   `json:"email,omitempty"`
	Telephone                          string   `json:"telephone"`
	IncType                            string   `json:"incType"`
	CompanyNumber                      string   `json:"companyNumber"`
	Website                            string   `json:"website"`
	DeclaredTurnover                   *int     `json:"declaredTurnover"`
	Description                        string   `json:"description"`
	Address                            string   `json:"address"`
	City                               string   `json:"city"`
	Region                             string   `json:"region"`
	PostalCode                         string   `json:"postalCode"`
	Country                            string   `json:"country"`
	Status                             string   `json:"status"`
	Offers                             []string `json:"offers,omitempty"`
	Wants                              []string `json:"wants,omitempty"`
	Categories                         []string `json:"categories,omitempty"`
	ShowTagsMatchedSinceLastLogin      bool     `json:"showTagsMatchedSinceLastLogin"`
	ReceiveDailyMatchNotificationEmail bool     `json:"receiveDailyMatchNotificationEmail"`
}

func NewAdminDeleteEntityRespond

func NewAdminDeleteEntityRespond(entity *Entity) *AdminDeleteEntityRespond

type AdminDeleteTagReq

type AdminDeleteTagReq struct {
	ID primitive.ObjectID `json:"name"`
}

func NewAdminDeleteTagReq

func NewAdminDeleteTagReq(r *http.Request) (*AdminDeleteTagReq, []error)

type AdminDeleteUser

type AdminDeleteUser struct {
	UserID primitive.ObjectID
}

func NewAdminDeleteUserReq

func NewAdminDeleteUserReq(r *http.Request) (*AdminDeleteUser, []error)

type AdminDeleteUserRespond

type AdminDeleteUserRespond struct {
	ID            string    `json:"id"`
	Email         string    `json:"email"`
	FirstName     string    `json:"firstName"`
	LastName      string    `json:"lastName"`
	Telephone     string    `json:"telephone"`
	LastLoginIP   string    `json:"lastLoginIP"`
	LastLoginDate time.Time `json:"lastLoginDate"`
}

func NewAdminDeleteUserRespond

func NewAdminDeleteUserRespond(user *User) *AdminDeleteUserRespond

type AdminEntityRespond

type AdminEntityRespond struct {
	ID                                 string   `json:"id"`
	AccountNumber                      string   `json:"accountNumber"`
	Name                               string   `json:"name"`
	Email                              string   `json:"email,omitempty"`
	Telephone                          string   `json:"telephone"`
	IncType                            string   `json:"incType"`
	CompanyNumber                      string   `json:"companyNumber"`
	Website                            string   `json:"website"`
	DeclaredTurnover                   *int     `json:"declaredTurnover"`
	Description                        string   `json:"description"`
	Address                            string   `json:"address"`
	City                               string   `json:"city"`
	Region                             string   `json:"region"`
	PostalCode                         string   `json:"postalCode"`
	Country                            string   `json:"country"`
	Status                             string   `json:"status"`
	Offers                             []string `json:"offers,omitempty"`
	Wants                              []string `json:"wants,omitempty"`
	Categories                         []string `json:"categories,omitempty"`
	ShowTagsMatchedSinceLastLogin      bool     `json:"showTagsMatchedSinceLastLogin"`
	ReceiveDailyMatchNotificationEmail bool     `json:"receiveDailyMatchNotificationEmail"`
}

func NewAdminEntityRespond

func NewAdminEntityRespond(entity *Entity) *AdminEntityRespond

type AdminGetEntity

type AdminGetEntity struct {
	EntityID string
}

func NewAdminGetEntityReq

func NewAdminGetEntityReq(r *http.Request) (*AdminGetEntity, []error)

type AdminGetEntityRespond

type AdminGetEntityRespond struct {
	ID                                 string                  `json:"id"`
	AccountNumber                      string                  `json:"accountNumber"`
	Name                               string                  `json:"name"`
	Email                              string                  `json:"email,omitempty"`
	Telephone                          string                  `json:"telephone"`
	IncType                            string                  `json:"incType"`
	CompanyNumber                      string                  `json:"companyNumber"`
	Website                            string                  `json:"website"`
	DeclaredTurnover                   *int                    `json:"declaredTurnover"`
	Description                        string                  `json:"description"`
	Address                            string                  `json:"address"`
	City                               string                  `json:"city"`
	Region                             string                  `json:"region"`
	PostalCode                         string                  `json:"postalCode"`
	Country                            string                  `json:"country"`
	Status                             string                  `json:"status"`
	Offers                             []string                `json:"offers,omitempty"`
	Wants                              []string                `json:"wants,omitempty"`
	Categories                         []string                `json:"categories,omitempty"`
	ShowTagsMatchedSinceLastLogin      bool                    `json:"showTagsMatchedSinceLastLogin"`
	ReceiveDailyMatchNotificationEmail bool                    `json:"receiveDailyMatchNotificationEmail"`
	Balance                            float64                 `json:"balance"`
	MaxPositiveBalance                 float64                 `json:"maxPositiveBalance"`
	MaxNegativeBalance                 float64                 `json:"maxNegativeBalance"`
	PendingTransfers                   []*AdminTransferRespond `json:"pendingTransfers"`
	Users                              []*AdminUserRespond     `json:"users"`
}

func NewAdminGetEntityRespond

func NewAdminGetEntityRespond(
	entity *Entity,
	users []*User,
	account *Account,
	balanceLimit *BalanceLimit,
	pendingTransfers []*AdminTransferRespond,
) *AdminGetEntityRespond

type AdminGetTransfer

type AdminGetTransfer struct {
	TransferID string
}

func NewAdminGetTransfer

func NewAdminGetTransfer(r *http.Request) (*AdminGetTransfer, []error)

type AdminGetUser

type AdminGetUser struct {
	UserID primitive.ObjectID
}

func NewAdminGetUserReq

func NewAdminGetUserReq(r *http.Request) (*AdminGetUser, []error)

type AdminGetUserRespond

type AdminGetUserRespond struct {
	ID            string                `json:"id"`
	Email         string                `json:"email"`
	FirstName     string                `json:"firstName"`
	LastName      string                `json:"lastName"`
	Telephone     string                `json:"telephone"`
	LastLoginIP   string                `json:"lastLoginIP"`
	LastLoginDate time.Time             `json:"lastLoginDate"`
	Entities      []*AdminEntityRespond `json:"entities"`
}

func NewAdminGetUserRespond

func NewAdminGetUserRespond(user *User, entities []*Entity) *AdminGetUserRespond

type AdminSearchEntityReq

type AdminSearchEntityReq struct {
	Page          int
	PageSize      int
	Name          string
	Email         string
	Statuses      []string
	Offers        []string
	Wants         []string
	TaggedSince   time.Time
	Category      string
	City          string
	Region        string
	Country       string
	AccountNumber string
	Balance       *float64
	MaxPosBal     *float64
	MaxNegBal     *float64
}

func NewAdminSearchEntityReq

func NewAdminSearchEntityReq(r *http.Request) (*AdminSearchEntityReq, []error)

type AdminSearchEntityRespond

type AdminSearchEntityRespond struct {
	ID                                 string              `json:"id"`
	AccountNumber                      string              `json:"accountNumber"`
	Name                               string              `json:"name"`
	Email                              string              `json:"email,omitempty"`
	Telephone                          string              `json:"telephone"`
	IncType                            string              `json:"incType"`
	CompanyNumber                      string              `json:"companyNumber"`
	Website                            string              `json:"website"`
	DeclaredTurnover                   *int                `json:"declaredTurnover"`
	Description                        string              `json:"description"`
	Address                            string              `json:"address"`
	City                               string              `json:"city"`
	Region                             string              `json:"region"`
	PostalCode                         string              `json:"postalCode"`
	Country                            string              `json:"country"`
	Status                             string              `json:"status"`
	Offers                             []string            `json:"offers,omitempty"`
	Wants                              []string            `json:"wants,omitempty"`
	Categories                         []string            `json:"categories,omitempty"`
	ShowTagsMatchedSinceLastLogin      bool                `json:"showTagsMatchedSinceLastLogin"`
	ReceiveDailyMatchNotificationEmail bool                `json:"receiveDailyMatchNotificationEmail"`
	Balance                            float64             `json:"balance"`
	MaxPositiveBalance                 float64             `json:"maxPositiveBalance"`
	MaxNegativeBalance                 float64             `json:"maxNegativeBalance"`
	Users                              []*AdminUserRespond `json:"users"`
}

func NewAdminSearchEntityRespond

func NewAdminSearchEntityRespond(
	entity *Entity,
	users []*User,
	account *Account,
	balanceLimit *BalanceLimit,
) *AdminSearchEntityRespond

type AdminSearchLogReq

type AdminSearchLogReq struct {
	Page       int
	PageSize   int
	Offset     int
	Email      string
	Categories []string
	Action     string
	Detail     string
	DateFrom   time.Time
	DateTo     time.Time
}

func NewAdminSearchLog

func NewAdminSearchLog(r *http.Request) (*AdminSearchLogReq, []error)

type AdminSearchTransferReq

type AdminSearchTransferReq struct {
	Page          int
	PageSize      int
	Offset        int
	Status        []string
	AccountNumber string
	DateFrom      time.Time
	DateTo        time.Time
}

func NewAdminSearchTransferQuery

func NewAdminSearchTransferQuery(r *http.Request) (*AdminSearchTransferReq, []error)

type AdminSearchTransferRespond

type AdminSearchTransferRespond struct {
	Transfers       []*AdminTransferRespond
	NumberOfResults int
	TotalPages      int
}

type AdminSearchUserReq

type AdminSearchUserReq struct {
	Email    string `json:"email"`
	LastName string `json:"last_name"`
	Page     int
	PageSize int
}

func NewAdminSearchUserReq

func NewAdminSearchUserReq(r *http.Request) (*AdminSearchUserReq, []error)

type AdminTransferReq

type AdminTransferReq struct {
	PayerEntity  *Entity
	PayeeEntity  *Entity
	TransferType string // "Transfer" / "AdminTranser"
	Amount       float64
	Description  string
}

func NewAdminTransferReq

func NewAdminTransferReq(userReq *AdminTransferUserReq, payerEntity *Entity, payeeEntity *Entity) (*AdminTransferReq, []error)

func (*AdminTransferReq) Validate

func (req *AdminTransferReq) Validate() []error

type AdminTransferRespond

type AdminTransferRespond struct {
	TransferID         string     `json:"id"`
	FromAccountNumber  string     `json:"fromAccountNumber"`
	FromEntityName     string     `json:"fromEntityName"`
	ToAccountNumber    string     `json:"toAccountNumber"`
	ToEntityName       string     `json:"toEntityName"`
	Amount             float64    `json:"amount"`
	Description        string     `json:"description"`
	Type               string     `json:"type,omitempty"`
	Status             string     `json:"status"`
	CancellationReason string     `json:"cancellationReason,omitempty"`
	CreatedAt          *time.Time `json:"dateProposed,omitempty"`
	CompletedAt        *time.Time `json:"dateCompleted,omitempty"`
}

func NewJournalToAdminTransferRespond

func NewJournalToAdminTransferRespond(j *Journal) *AdminTransferRespond

func NewJournalsToAdminTransfersRespond

func NewJournalsToAdminTransfersRespond(journals []*Journal) []*AdminTransferRespond

type AdminTransferUserReq

type AdminTransferUserReq struct {
	Payer       string  `json:"payer"`
	Payee       string  `json:"payee"`
	Amount      float64 `json:"amount"`
	Description string  `json:"description"`
}

type AdminUpdateCategoryReq

type AdminUpdateCategoryReq struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

func NewAdminUpdateCategoryReq

func NewAdminUpdateCategoryReq(r *http.Request) (*AdminUpdateCategoryReq, []error)

type AdminUpdateEntityJSON

type AdminUpdateEntityJSON struct {
	Status           string    `json:"status"`
	Name             string    `json:"name"`
	Email            string    `json:"email"`
	Telephone        string    `json:"telephone"`
	IncType          string    `json:"incType"`
	CompanyNumber    string    `json:"companyNumber"`
	Website          string    `json:"website"`
	DeclaredTurnover *int      `json:"declaredTurnover"`
	Description      string    `json:"description"`
	Users            *[]string `json:"users"`
	// Tags
	Offers     *[]string `json:"offers"`
	Wants      *[]string `json:"wants"`
	Categories *[]string `json:"categories"`
	// Address
	Address    string `json:"address"`
	City       string `json:"city"`
	Region     string `json:"region"`
	PostalCode string `json:"postalCode"`
	Country    string `json:"country"`
	// flags
	ReceiveDailyMatchNotificationEmail *bool `json:"receiveDailyMatchNotificationEmail"`
	ShowTagsMatchedSinceLastLogin      *bool `json:"showTagsMatchedSinceLastLogin"`
	// Account
	MaxPosBal *float64 `json:"maxPositiveBalance"`
	MaxNegBal *float64 `json:"maxNegativeBalance"`
	// Useless (Do not use it)
	ID            string `json:"id"`
	AccountNumber string `json:"accountNumber"`
}

type AdminUpdateEntityReq

type AdminUpdateEntityReq struct {
	OriginEntity                       *Entity
	OriginBalanceLimit                 *BalanceLimit
	Status                             string
	Name                               string
	Email                              string
	Telephone                          string
	IncType                            string
	CompanyNumber                      string
	Website                            string
	DeclaredTurnover                   *int
	Description                        string
	ReceiveDailyMatchNotificationEmail *bool
	ShowTagsMatchedSinceLastLogin      *bool
	// Users
	Users        *[]string
	AddedUsers   []primitive.ObjectID
	RemovedUsers []primitive.ObjectID
	// Tags
	Offers        *[]string
	AddedOffers   []string
	RemovedOffers []string
	Wants         *[]string
	AddedWants    []string
	RemovedWants  []string
	Categories    *[]string
	// Address
	Address    string
	City       string
	Region     string
	PostalCode string
	Country    string
	// Account
	MaxPosBal *float64
	MaxNegBal *float64
}

func NewAdminUpdateEntityReq

func NewAdminUpdateEntityReq(j AdminUpdateEntityJSON, originEntity *Entity, originBalanceLimit *BalanceLimit) (*AdminUpdateEntityReq, []error)

type AdminUpdateEntityRespond

type AdminUpdateEntityRespond struct {
	ID                                 string              `json:"id"`
	AccountNumber                      string              `json:"accountNumber"`
	Name                               string              `json:"name"`
	Email                              string              `json:"email,omitempty"`
	Telephone                          string              `json:"telephone"`
	IncType                            string              `json:"incType"`
	CompanyNumber                      string              `json:"companyNumber"`
	Website                            string              `json:"website"`
	DeclaredTurnover                   *int                `json:"declaredTurnover"`
	Description                        string              `json:"description"`
	Address                            string              `json:"address"`
	City                               string              `json:"city"`
	Region                             string              `json:"region"`
	PostalCode                         string              `json:"postalCode"`
	Country                            string              `json:"country"`
	Status                             string              `json:"status"`
	Offers                             []string            `json:"offers,omitempty"`
	Wants                              []string            `json:"wants,omitempty"`
	Categories                         []string            `json:"categories,omitempty"`
	ShowTagsMatchedSinceLastLogin      bool                `json:"showTagsMatchedSinceLastLogin"`
	ReceiveDailyMatchNotificationEmail bool                `json:"receiveDailyMatchNotificationEmail"`
	MaxPositiveBalance                 float64             `json:"maxPositiveBalance"`
	MaxNegativeBalance                 float64             `json:"maxNegativeBalance"`
	Users                              []*AdminUserRespond `json:"users"`
	// To log user action.
	BalanceLimit *BalanceLimit `json:"-"`
}

func NewAdminUpdateEntityRespond

func NewAdminUpdateEntityRespond(users []*User, entity *Entity, balanceLimit *BalanceLimit) *AdminUpdateEntityRespond

type AdminUpdateTagReq

type AdminUpdateTagReq struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

func NewAdminUpdateTagReq

func NewAdminUpdateTagReq(r *http.Request) (*AdminUpdateTagReq, []error)

type AdminUpdateUserJSON

type AdminUpdateUserJSON struct {
	Email     string    `json:"email"`
	FirstName string    `json:"firstName"`
	LastName  string    `json:"lastName"`
	Telephone string    `json:"telephone"`
	Password  string    `json:"password"`
	Entities  *[]string `json:"entities"`
}

type AdminUpdateUserReq

type AdminUpdateUserReq struct {
	OriginUser *User
	Email      string
	FirstName  string
	LastName   string
	Telephone  string
	Password   string
	// Entity
	Entity          *[]string
	AddedEntities   []primitive.ObjectID
	RemovedEntities []primitive.ObjectID
}

func NewAdminUpdateUserReq

func NewAdminUpdateUserReq(j AdminUpdateUserJSON, originUser *User) (*AdminUpdateUserReq, []error)

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 AdminUserRespond

type AdminUserRespond struct {
	ID            string    `json:"id"`
	Email         string    `json:"email"`
	FirstName     string    `json:"firstName"`
	LastName      string    `json:"lastName"`
	Telephone     string    `json:"telephone"`
	LastLoginIP   string    `json:"lastLoginIP"`
	LastLoginDate time.Time `json:"lastLoginDate"`
}

func NewAdminUserRespond

func NewAdminUserRespond(user *User) *AdminUserRespond

type BalanceLimit

type BalanceLimit struct {
	gorm.Model
	// `BalanceLimit` belongs to `Account`, `AccountID` is the foreign key
	Account       Account
	AccountNumber string  `json:"accountNumber,omitempty" gorm:"type:varchar(16);not null;unique_index"`
	MaxNegBal     float64 `json:"maxNegBal,omitempty" gorm:"type:real;not null"`
	MaxPosBal     float64 `json:"maxPosBal,omitempty" gorm:"type:real;not null"`
}

type BalanceReq

type BalanceReq struct {
	QueryingEntityID string
}

func NewBalanceQuery

func NewBalanceQuery(r *http.Request) (*BalanceReq, []error)

func (*BalanceReq) Validate

func (query *BalanceReq) Validate() []error

type Category

type Category 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"`
}

type CategoryRespond

type CategoryRespond struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

func NewCategoryRespond

func NewCategoryRespond(category *Category) *CategoryRespond

func NewSearchCategoryRespond

func NewSearchCategoryRespond(categories []*Category) []*CategoryRespond

type ESSearchEntityResult

type ESSearchEntityResult struct {
	IDs             []string
	NumberOfResults int
	TotalPages      int
}

type ESSearchJournalResult

type ESSearchJournalResult struct {
	IDs             []string
	NumberOfResults int
	TotalPages      int
}

type ESSearchUserActionResult

type ESSearchUserActionResult struct {
	UserActions     []*UserActionESRecord
	NumberOfResults int
	TotalPages      int
}

type ESSearchUserResult

type ESSearchUserResult struct {
	UserIDs         []string
	NumberOfResults int
	TotalPages      int
}

type EmailReq

type EmailReq struct {
	SenderEntityID   string `json:"senderEntityID"`
	ReceiverEntityID string `json:"receiverEntityID"`
	Body             string `json:"body"`
}

func NewEmailReq

func NewEmailReq(r *http.Request) (*EmailReq, []error)

type Entity

type Entity 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"`

	Users []primitive.ObjectID `json:"users,omitempty" bson:"users,omitempty"`

	Name             string      `json:"name,omitempty" bson:"name,omitempty"`
	Telephone        string      `json:"telephone,omitempty" bson:"telephone,omitempty"`
	Email            string      `json:"email,omitempty" bson:"email,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"`
	DeclaredTurnover *int        `json:"declaredTurnover,omitempty" bson:"declaredTurnover,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"`
	Address          string      `json:"address,omitempty" bson:"address,omitempty"`
	City             string      `json:"city,omitempty" bson:"city,omitempty"`
	Region           string      `json:"region,omitempty" bson:"region,omitempty"`
	PostalCode       string      `json:"postalCode,omitempty" bson:"postalCode,omitempty"`
	Country          string      `json:"country,omitempty" bson:"country,omitempty"`
	Status           string      `json:"status,omitempty" bson:"status,omitempty"`
	Categories       []string    `json:"categories,omitempty" bson:"categories,omitempty"`
	// Timestamp when trading status applied
	MemberStartedAt time.Time `json:"memberStartedAt,omitempty" bson:"memberStartedAt,omitempty"`

	// flags
	ShowTagsMatchedSinceLastLogin      *bool `json:"showTagsMatchedSinceLastLogin,omitempty" bson:"showTagsMatchedSinceLastLogin,omitempty"`
	ReceiveDailyMatchNotificationEmail *bool `json:"receiveDailyMatchNotificationEmail,omitempty" bson:"receiveDailyMatchNotificationEmail,omitempty"`

	LastNotificationSentDate time.Time `json:"lastNotificationSentDate,omitempty" bson:"lastNotificationSentDate,omitempty"`

	AccountNumber    string               `json:"accountNumber,omitempty" bson:"accountNumber,omitempty"`
	FavoriteEntities []primitive.ObjectID `json:"favoriteEntities,omitempty" bson:"favoriteEntities,omitempty"`
}

Entity is the model representation of a entity in the data model.

func (*Entity) Validate

func (entity *Entity) Validate() []error

type EntityESRecord

type EntityESRecord struct {
	ID     string `json:"id,omitempty"`
	Name   string `json:"name,omitempty"`
	Email  string `json:"email,omitempty"`
	Status string `json:"status,omitempty"`
	// Tags
	Offers     []*TagField `json:"offers,omitempty"`
	Wants      []*TagField `json:"wants,omitempty"`
	Categories []string    `json:"categories,omitempty"`
	// Address
	City    string `json:"city,omitempty"`
	Region  string `json:"region,omitempty"`
	Country string `json:"country,omitempty"`
	// Account
	AccountNumber string   `json:"accountNumber,omitempty"`
	Balance       *float64 `json:"balance,omitempty"`
	MaxNegBal     *float64 `json:"maxNegBal,omitempty"`
	MaxPosBal     *float64 `json:"maxPosBal,omitempty"`
}

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

type EntityRespond

type EntityRespond struct {
	ID                                 string             `json:"id"`
	AccountNumber                      string             `json:"accountNumber"`
	Name                               string             `json:"name"`
	Email                              string             `json:"email,omitempty"`
	Telephone                          string             `json:"telephone"`
	IncType                            string             `json:"incType"`
	CompanyNumber                      string             `json:"companyNumber"`
	Website                            string             `json:"website"`
	DeclaredTurnover                   *int               `json:"declaredTurnover"`
	Description                        string             `json:"description"`
	Address                            string             `json:"address"`
	City                               string             `json:"city"`
	Region                             string             `json:"region"`
	PostalCode                         string             `json:"postalCode"`
	Country                            string             `json:"country"`
	Status                             string             `json:"status"`
	ShowTagsMatchedSinceLastLogin      bool               `json:"showTagsMatchedSinceLastLogin"`
	ReceiveDailyMatchNotificationEmail bool               `json:"receiveDailyMatchNotificationEmail"`
	Offers                             []string           `json:"offers"`
	Wants                              []string           `json:"wants"`
	Categories                         []string           `json:"categories"`
	Balance                            float64            `json:"balance"`
	MaxPositiveBalance                 float64            `json:"maxPositiveBalance"`
	MaxNegativeBalance                 float64            `json:"maxNegativeBalance"`
	PendingTransfers                   []*TransferRespond `json:"pendingTransfers"`
}

func NewEntityRespond

func NewEntityRespond(
	entity *Entity,
	account *Account,
	balanceLimit *BalanceLimit,
	pendingTransfers []*TransferRespond,
) *EntityRespond

type FindCategoryResult

type FindCategoryResult struct {
	Categories      []*Category
	NumberOfResults int
	TotalPages      int
}

type FindTagResult

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

type GetEntity

type GetEntity struct {
	SearchEntityID   string
	QueryingEntityID string
}

func NewGetEntityReq

func NewGetEntityReq(r *http.Request) (*GetEntity, []error)

type Journal

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

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

	InitiatedBy string `gorm:"varchar(16);not null;default:''"`

	FromAccountNumber string `gorm:"varchar(16);not null;default:''"`
	FromEntityName    string `gorm:"type:varchar(120);not null;default:''"`

	ToAccountNumber string `gorm:"varchar(16);not null;default:''"`
	ToEntityName    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:''"`

	CompletedAt time.Time

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

type JournalESRecord

type JournalESRecord struct {
	TransferID        string    `json:"transferID,omitempty"`
	FromAccountNumber string    `json:"fromAccountNumber,omitempty"`
	ToAccountNumber   string    `json:"toAccountNumber,omitempty"`
	Status            string    `json:"status,omitempty"`
	CreatedAt         time.Time `json:"createdAt,omitempty"`
}

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 LoginReq

type LoginReq struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

func NewLoginReq

func NewLoginReq(r *http.Request) (*LoginReq, []error)

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 `json:"matchedOffers,omitempty"`
	MatchedWants  map[string][]string `json:"matchedWants,omitempty"`
}

type PasswordChange

type PasswordChange struct {
	Password string `json:"password"`
}

func (*PasswordChange) Validate

func (req *PasswordChange) Validate() []error

type Posting

type Posting struct {
	gorm.Model
	AccountNumber string  `gorm:"varchar(16);not null;default:''"`
	JournalID     uint    `gorm:"not null"`
	Amount        float64 `gorm:"not null"`
}

type ProposeTransferRespond

type ProposeTransferRespond struct {
	ID          string     `json:"id"`
	From        string     `json:"from"`
	To          string     `json:"to"`
	Amount      float64    `json:"amount"`
	Description string     `json:"description"`
	Status      string     `json:"status"`
	CreatedAt   *time.Time `json:"dateProposed,omitempty"`
}

func NewProposeTransferRespond

func NewProposeTransferRespond(journal *Journal) *ProposeTransferRespond

type ResetPasswordReq

type ResetPasswordReq struct {
	Password string `json:"password"`
}

func (*ResetPasswordReq) Validate

func (req *ResetPasswordReq) Validate() []error

type SearchCategoryReq

type SearchCategoryReq struct {
	Fragment string `json:"fragment"`
	Prefix   string `json:"prefix"`
	Page     int    `json:"page"`
	PageSize int    `json:"pageSize"`
}

func NewSearchCategoryReq

func NewSearchCategoryReq(q url.Values) (*SearchCategoryReq, error)

func (*SearchCategoryReq) Validate

func (query *SearchCategoryReq) Validate() []error

type SearchEntityReq

type SearchEntityReq struct {
	QueryingEntityID string
	Page             int
	PageSize         int
	Name             string
	Wants            []string
	Offers           []string
	Category         string
	FavoriteEntities []primitive.ObjectID
	FavoritesOnly    bool
	TaggedSince      time.Time
	Statuses         []string

	Country string
	City    string
}

func NewSearchEntityReq

func NewSearchEntityReq(q url.Values) (*SearchEntityReq, error)

func (*SearchEntityReq) Validate

func (query *SearchEntityReq) Validate() []error

type SearchEntityRespond

type SearchEntityRespond struct {
	ID               string   `json:"id"`
	AccountNumber    string   `json:"accountNumber"`
	Name             string   `json:"name"`
	Email            string   `json:"email,omitempty"`
	Telephone        string   `json:"telephone"`
	IncType          string   `json:"incType"`
	CompanyNumber    string   `json:"companyNumber"`
	Website          string   `json:"website"`
	DeclaredTurnover *int     `json:"declaredTurnover"`
	Description      string   `json:"description"`
	Address          string   `json:"address"`
	City             string   `json:"city"`
	Region           string   `json:"region"`
	PostalCode       string   `json:"postalCode"`
	Country          string   `json:"country"`
	Status           string   `json:"status"`
	Offers           []string `json:"offers"`
	Wants            []string `json:"wants"`
	Categories       []string `json:"categories"`
	IsFavorite       bool     `json:"isFavorite"`
}

func NewSearchEntityRespond

func NewSearchEntityRespond(entity *Entity, queryingEntityStatus string, favoriteEntities []primitive.ObjectID) *SearchEntityRespond

type SearchEntityResult

type SearchEntityResult struct {
	Entities        []*Entity
	NumberOfResults int
	TotalPages      int
}

type SearchTagReq

type SearchTagReq struct {
	Fragment string `json:"fragment"`
	Page     int    `json:"page"`
	PageSize int    `json:"pageSize"`
}

func NewSearchTagReq

func NewSearchTagReq(q url.Values) (*SearchTagReq, error)

func (*SearchTagReq) Validate

func (q *SearchTagReq) Validate() []error

type SearchTransferReq

type SearchTransferReq struct {
	Page                  int
	PageSize              int
	Status                string
	QueryingEntityID      string
	QueryingAccountNumber string
	Offset                int
}

func NewSearchTransferQuery

func NewSearchTransferQuery(r *http.Request, entity *Entity) (*SearchTransferReq, []error)

type SearchTransferRespond

type SearchTransferRespond struct {
	Transfers       []*TransferRespond
	NumberOfResults int
	TotalPages      int
}

type SearchUserResult

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

type SignupReq

type SignupReq struct {
	UserEmail        string   `json:"userEmail"`
	EntityEmail      string   `json:"entityEmail"`
	Password         string   `json:"password"`
	FirstName        string   `json:"firstName"`
	LastName         string   `json:"lastName"`
	UserPhone        string   `json:"userPhone"`
	EntityName       string   `json:"entityName"`
	IncType          string   `json:"incType"`
	CompanyNumber    string   `json:"companyNumber"`
	EntityPhone      string   `json:"entityPhone"`
	Website          string   `json:"website"`
	DeclaredTurnover *int     `json:"declaredTurnover"`
	Description      string   `json:"description"`
	Address          string   `json:"address"`
	City             string   `json:"city"`
	Region           string   `json:"region"`
	PostalCode       string   `json:"postalCode"`
	Country          string   `json:"country"`
	Offers           []string `json:"offers"`
	Wants            []string `json:"wants"`
	// flags
	ShowTagsMatchedSinceLastLogin      *bool `json:"showTagsMatchedSinceLastLogin"`
	ReceiveDailyMatchNotificationEmail *bool `json:"receiveDailyMatchNotificationEmail"`
}

func NewSignupReq

func NewSignupReq(r *http.Request) (*SignupReq, []error)

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"`
}

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"`
}

func ToTagFields

func ToTagFields(tags []string) []*TagField

ToTagFields converts tags into TagFields.

type TagRespond

type TagRespond struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

func NewSearchTagRespond

func NewSearchTagRespond(tags []*Tag) []*TagRespond

func NewTagRespond

func NewTagRespond(tag *Tag) *TagRespond

type TransferReq

type TransferReq struct {
	TransferDirection string // "in" or "out"
	TransferType      string // "Transfer" / "AdminTranser"

	InitiatorAccountNumber string
	ReceiverAccountNumber  string
	Amount                 float64
	Description            string

	InitiatorEmail      string
	InitiatorEntityName string

	ReceiverEmail      string
	ReceiverEntityName string

	FromAccountNumber string
	FromEmail         string
	FromEntityName    string
	FromStatus        string

	ToAccountNumber string
	ToEmail         string
	ToEntityName    string
	ToStatus        string

	InitiatorEntity *Entity
	ReceiverEntity  *Entity
}

func NewTransferReq

func NewTransferReq(userReq *TransferUserReq, initiatorEntity *Entity, receiverEntity *Entity) (*TransferReq, []error)

func (*TransferReq) Validate

func (req *TransferReq) Validate() []error

type TransferRespond

type TransferRespond struct {
	TransferID         string     `json:"id"`
	Transfer           string     `json:"transfer"`
	IsInitiator        bool       `json:"isInitiator"`
	AccountNumber      string     `json:"accountNumber"`
	EntityName         string     `json:"entityName"`
	Amount             float64    `json:"amount"`
	Description        string     `json:"description"`
	Status             string     `json:"status"`
	CancellationReason string     `json:"cancellationReason,omitempty"`
	CreatedAt          *time.Time `json:"dateProposed,omitempty"`
	CompletedAt        *time.Time `json:"dateCompleted,omitempty"`
}

func NewJournalsToTransfersRespond

func NewJournalsToTransfersRespond(journals []*Journal, queryingAccountNumber string) []*TransferRespond

type TransferUserReq

type TransferUserReq struct {
	TransferDirection      string  `json:"transfer"`
	InitiatorAccountNumber string  `json:"initiator"`
	ReceiverAccountNumber  string  `json:"receiver"`
	Amount                 float64 `json:"amount"`
	Description            string  `json:"description"`
}

type UpdateOfferAndWants

type UpdateOfferAndWants struct {
	EntityID      primitive.ObjectID
	OriginStatus  string
	UpdatedStatus string
	UpdatedOffers []string
	UpdatedWants  []string
	AddedOffers   []string
	AddedWants    []string
}

type UpdateTransferReq

type UpdateTransferReq struct {
	TransferID         string
	Action             string
	CancellationReason string

	LoggedInUserID string

	Journal        *Journal
	InitiateEntity *Entity
	FromEntity     *Entity
	ToEntity       *Entity
}

func NewUpdateTransferReq

func NewUpdateTransferReq(
	r *http.Request,
	journal *Journal,
	initiateEntity *Entity,
	fromEntity *Entity,
	toEntity *Entity,
) (*UpdateTransferReq, []error)

func (*UpdateTransferReq) Validate

func (req *UpdateTransferReq) Validate() []error

type UpdateUserEntityJSON

type UpdateUserEntityJSON struct {
	Name             string `json:"name"`
	Email            string `json:"email"`
	Telephone        string `json:"telephone"`
	IncType          string `json:"incType"`
	CompanyNumber    string `json:"companyNumber"`
	Website          string `json:"website"`
	DeclaredTurnover *int   `json:"declaredTurnover"`
	Description      string `json:"description"`
	Address          string `json:"address"`
	City             string `json:"city"`
	Region           string `json:"region"`
	PostalCode       string `json:"postalCode"`
	Country          string `json:"country"`
	// Tags
	Offers *[]string `json:"offers"`
	Wants  *[]string `json:"wants"`
	// flags
	ShowTagsMatchedSinceLastLogin      *bool `json:"showTagsMatchedSinceLastLogin"`
	ReceiveDailyMatchNotificationEmail *bool `json:"receiveDailyMatchNotificationEmail"`
	// Not allow to change
	ID     string `json:"id"`
	Status string `json:"status"`
}

type UpdateUserEntityReq

type UpdateUserEntityReq struct {
	OriginEntity     *Entity
	Name             string
	Email            string
	Telephone        string
	IncType          string
	CompanyNumber    string
	Website          string
	DeclaredTurnover *int
	Description      string
	// Address
	Address    string
	City       string
	Region     string
	PostalCode string
	Country    string
	// Tags
	Offers        *[]string
	AddedOffers   []string
	RemovedOffers []string
	Wants         *[]string
	AddedWants    []string
	RemovedWants  []string
	// flags
	ShowTagsMatchedSinceLastLogin      *bool `json:"showTagsMatchedSinceLastLogin"`
	ReceiveDailyMatchNotificationEmail *bool `json:"receiveDailyMatchNotificationEmail"`
}

func NewUpdateUserEntityReq

func NewUpdateUserEntityReq(j UpdateUserEntityJSON, originEntity *Entity) (*UpdateUserEntityReq, []error)

type UpdateUserReq

type UpdateUserReq struct {
	ID        string `json:"id"`
	Email     string `json:"email"`
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
	Telephone string `json:"telephone"`
}

func NewUpdateUserReq

func NewUpdateUserReq(r *http.Request) (*UpdateUserReq, []error)

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"`
	Entities  []primitive.ObjectID `json:"entities,omitempty" bson:"entities,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"`
}

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

func (*User) Validate

func (user *User) Validate() []error

type UserAction

type UserAction struct {
	ID        primitive.ObjectID `bson:"_id,omitempty"`
	UserID    primitive.ObjectID `bson:"userID,omitempty"`
	Email     string             `bson:"email,omitempty"`
	Action    string             `bson:"action,omitempty"`
	Detail    string             `bson:"detail,omitempty"`
	Category  string             `bson:"category,omitempty"`
	CreatedAt time.Time          `bson:"createdAt,omitempty"`
}

type UserActionESRecord

type UserActionESRecord struct {
	UserID    string    `json:"userID,omitempty"`
	Email     string    `json:"email,omitempty"`
	Action    string    `json:"action,omitempty"`
	Detail    string    `json:"detail,omitempty"`
	Category  string    `json:"category,omitempty"`
	CreatedAt time.Time `json:"createdAt,omitempty"`
}

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.

type UserRespond

type UserRespond struct {
	ID            string    `json:"id"`
	Email         string    `json:"email"`
	FirstName     string    `json:"firstName"`
	LastName      string    `json:"lastName"`
	Telephone     string    `json:"telephone"`
	LastLoginIP   string    `json:"lastLoginIP"`
	LastLoginDate time.Time `json:"lastLoginDate"`
}

func NewUserRespond

func NewUserRespond(user *User) *UserRespond

Jump to

Keyboard shortcuts

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