model

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResultsPerPage    = 10.0
	MaxPagesNavigator = 5
)
View Source
const (
	RoleRegular = iota + 1
	RoleAdmin
)

Variables

This section is empty.

Functions

func Hash

func Hash(s string) string

func Paginate

func Paginate(currentPage int, pageSize int) func(db *gorm.DB) *gorm.DB

Types

type User

type User struct {
	gorm.Model
	Uuid               string `gorm:"uniqueIndex"`
	Name               string
	Email              string `gorm:"uniqueIndex"`
	SendToEmail        string
	Password           string
	Role               int
	WordsPerMinute     float64
	RecoveryUUID       string
	RecoveryValidUntil time.Time
}

func (User) ConfirmPassword

func (u User) ConfirmPassword(confirmPassword string, minPasswordLength int, errs map[string]string) map[string]string

func (User) Validate

func (u User) Validate(minPasswordLength int) map[string]string

Validate checks all user's fields to ensure they are in the required format

type UserRepository

type UserRepository struct {
	DB *gorm.DB
}

func (*UserRepository) Admins

func (u *UserRepository) Admins() int64

func (*UserRepository) Create

func (u *UserRepository) Create(user User) error

func (*UserRepository) Delete

func (u *UserRepository) Delete(uuid string) error

func (*UserRepository) FindByEmail

func (u *UserRepository) FindByEmail(email string) (User, error)

func (*UserRepository) FindByRecoveryUuid

func (u *UserRepository) FindByRecoveryUuid(recoveryUuid string) (User, error)

func (*UserRepository) FindByUuid

func (u *UserRepository) FindByUuid(uuid string) (User, error)

func (*UserRepository) List

func (u *UserRepository) List(page int, resultsPerPage int) ([]User, error)

func (*UserRepository) Total

func (u *UserRepository) Total() int64

func (*UserRepository) Update

func (u *UserRepository) Update(user User) error

Jump to

Keyboard shortcuts

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