model

package
v0.0.0-...-a03da9d Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BankGenerator

func BankGenerator() interface{}

func RateLimiterFunc

func RateLimiterFunc(request *goyave.Request) ratelimiter.Config

RateLimiterFunc returns rate limiting configuration Anonymous users have a quota of 50 requests per minute while Authenticated users are limited to 500 requests per minute.

func UserGenerator

func UserGenerator() interface{}

UserGenerator generator function for the User model. Generate users using the following: database.NewFactory(model.UserGenerator).Generate(5)

Types

type Bank

type Bank struct {
	CreatedAt  time.Time      `json:"created_at"`
	UpdatedAt  time.Time      `json:"updated_at"`
	DeletedAt  gorm.DeletedAt `json:"deleted_at"`
	ID         uint64         `json:"id" gorm:"primarykey"`
	Balance    float64        `json:"balance"`
	UserID     uint64         `json:"user_id" gorm:"not null"`
	Operations []Operation    `json:"-"` //TODO : replace "-""
}

Bank represents a bank account

type Operation

type Operation struct {
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at"`
	ID        uint64         `json:"id" gorm:"primarykey"`
	Amount    float64        `json:"amount"`
	From      string         `json:"from"`
	To        string         `json:"to"`
	SenderID  uint64         `json:"sender_id" gorm:"not null"`
	BankID    uint64         `json:"receiver_id" gorm:"not null"` // Foreign key of table bank
	Invoice   bool           `json:"invoice"`
	Acquitted bool           `json:"acquitted"`
	DueDate   time.Time      `json:"due_date"`
	Transfer  bool           `json:"transfer"`
	Instant   bool           `json:"instant"`
	Scheduled bool           `json:"scheduled"`
	Date      time.Time      `json:"date"`
	Question  string         `json:"question"`
	Answer    string         `json:"answer"`
	Verified  bool           `json:"verified"`
	Try       uint           `json:"try"`
}

Operation represents a operation account

type User

type User struct {
	CreatedAt        time.Time      `json:"created_at"`
	UpdatedAt        time.Time      `json:"updated_at"`
	DeletedAt        gorm.DeletedAt `json:"deleted_at"`
	ID               uint64         `json:"id" gorm:"primarykey"`
	Email            string         `json:"email" gorm:"type:char(100);uniqueIndex;not null" auth:"username"`
	Password         string         `json:"-" gorm:"size:64;not null" auth:"password"`
	FirstName        string         `json:"first_name"`
	LastName         string         `json:"last_name"`
	Verified         bool           `json:"verified"`
	VerificationCode string         `json:"verification_code"`
	Banks            []Bank         `json:"-"`
}

User represents a user

func (*User) BeforeCreate

func (u *User) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook executed before a User record is inserted in the database. Ensures the password is encrypted using bcrypt, with the cost defined by the config entry "app.bcryptCost".

func (*User) BeforeUpdate

func (u *User) BeforeUpdate(tx *gorm.DB) error

BeforeUpdate hook executed before a User record is updated in the database. Ensures the password is encrypted using bcrypt, with the cost defined by the config entry "app.bcryptCost".

Jump to

Keyboard shortcuts

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