models

package
v0.0.0-...-96f74f2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AnonymousUser = &User{}

Functions

func ValidateFilters

func ValidateFilters(v *validator.MyValidator, f Filters)

Types

type Categories

type Categories []string
var CategoriesList Categories = []string{
	"Sport",
	"Home",
	"Work",
}

func (Categories) GetCategory

func (c Categories) GetCategory(categoryId uint8) (string, error)

func (Categories) IsValidCategory

func (c Categories) IsValidCategory(categoryId uint8) bool

type Email

type Email struct {
	To      rabbitmq.Receiver  `json:"to"`
	Type    rabbitmq.EmailType `json:"type"`
	Message string             `json:"message"`
}

type Filters

type Filters struct {
	Page         uint32
	PageSize     uint32
	Sort         string
	SortSafelist []string
}

func (Filters) Limit

func (f Filters) Limit() uint32

func (Filters) Offset

func (f Filters) Offset() uint32

func (Filters) SortColumn

func (f Filters) SortColumn() string

func (Filters) SortDirection

func (f Filters) SortDirection() string

type Metadata

type Metadata struct {
	CurrentPage  uint32 `json:"current_page,omitempty"`
	PageSize     uint32 `json:"page_size,omitempty"`
	FirstPage    uint32 `json:"first_page,omitempty"`
	LastPage     uint32 `json:"last_page,omitempty"`
	TotalRecords uint32 `json:"total_records,omitempty"`
}

Metadata defines a new struct for holding the pagination metadata.

func CalculateMetadata

func CalculateMetadata(totalRecords, page, pageSize uint32) Metadata

type Password

type Password struct {
	Plaintext *string
	Hash      []byte
}

func (*Password) Matches

func (p *Password) Matches(plaintextPassword string) (bool, error)

func (*Password) Set

func (p *Password) Set(plaintextPassword string) error

type Paste

type Paste struct {
	Id        uint16    `json:"id"`
	Title     string    `json:"title"`
	Category  uint8     `json:"category,omitempty"`
	Text      string    `json:"text"`
	CreatedAt time.Time `json:"created_at"`
	ExpiresAt time.Time `json:"expires_at"`
	Minutes   int32     `json:"-"`
	Version   uint32    `json:"version"`
	CanEdit   bool      `json:"can_edit"`
}

type Permission

type Permission struct {
	PasteId uint16 `json:"paste_id"`
	UserId  int64  `json:"user_id"`
}

type Token

type Token struct {
	Plaintext string    `json:"token"`
	Hash      []byte    `json:"-"`
	UserID    int64     `json:"-"`
	Expiry    time.Time `json:"expiry"`
	Scope     string    `json:"-"`
}

func GenerateToken

func GenerateToken(userID int64, ttl time.Duration, scope string) (*Token, error)

type User

type User struct {
	ID        int64     `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	Login     string    `json:"login"`
	Email     string    `json:"email"`
	Password  Password  `json:"-"`
	Activated bool      `json:"activated"`
	Version   int       `json:"-"`
}

func (*User) IsAnonymous

func (u *User) IsAnonymous() bool

Jump to

Keyboard shortcuts

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