model

package
v0.0.0-...-3545448 Latest Latest
Warning

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

Go to latest
Published: May 21, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDBMySQL = "false"
	EnvPort        = "PORT"
)
View Source
const (
	RoleAdmin     = "admin"
	RoleClient    = "client"
	RoleModerator = "moderator"
	RoleService   = "service"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array []Object

type ArrayCSV

type ArrayCSV []CSV

type ArrayJson

type ArrayJson []Json

type ArrayKV

type ArrayKV []KV

type CSV

type CSV Json

type ConfigAPI

type ConfigAPI struct {
	ConfigAuth
	ConfigDB
	ConfigEmail
	Port uint16
}

type ConfigDB

type ConfigDB struct {
	providers.MySQL
	providers.SQLite
}

type ConfigEmail

type ConfigEmail struct {
	providers.Twilio // todo: use providers.Google
}

type Email

type Email struct {
	From    *mail.Email
	HTML    string
	Subject string
	Text    string
	To      *mail.Email
}

type Json

type Json map[string]interface{}

type KV

type KV map[interface{}]interface{}

type Login

type Login struct {
	Model
	Client string `json:"client" validate:"required"` // todo: size
	IP     string `json:"ip" validate:"required"`     // todo: regex
	Type   string `json:"type" validate:"required"`   // todo: enum
}

type Model

type Model struct {
	ID          uint           `json:"id" gorm:"primarykey"`
	CreatedAt   time.Time      `json:"createdAt"`
	CreatedByID uint           `json:"createdByID,omitempty" gorm:"index"`
	UpdatedAt   time.Time      `json:"updatedAt"`
	UpdatedByID uint           `json:"updatedByID,omitempty"`
	DeletedAt   gorm.DeletedAt `json:"-" gorm:"index"`
}

type Notification

type Notification struct {
	Model
	Description string `json:"description" validate:"min=3,max=256"`
	Name        string `json:"name" validate:"min=3,max=64"`
	Seen        bool   `json:"seen"`
	UserID      uint   `json:"userID" validate:"required"`
}

type NotificationDTO

type NotificationDTO struct {
	ID          uint   `json:"id" gorm:"primarykey"`
	CreatedByID uint   `json:"createdByID"`
	Description string `json:"description"`
	Name        string `json:"name"`
	Seen        bool   `json:"seen"`
	UserID      uint   `json:"userID"`
}

type Object

type Object interface{}

type PasswordReset

type PasswordReset struct {
	Code     string `json:"code"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

type SMS

type SMS struct {
	To   string `json:"to" validate:"required"`
	Body string `json:"body" validate:"required"`
}

type User

type User struct {
	Model
	Address       string         `json:"address,omitempty" validate:"max=128"`
	AuthID        string         `json:"authID,omitempty"`
	AuthProvider  string         `json:"authProvider,omitempty"`
	Dob           time.Time      `json:"dob,omitempty"` // todo: date validation
	FirstName     string         `json:"firstName" validate:"min=1,max=64"`
	LastName      string         `json:"lastName" validate:"min=2,max=64"`
	Email         string         `json:"email,omitempty" gorm:"uniqueIndex,size:255" validate:"email,max=64"` // todo: required if no mobile
	History       []Login        `json:"history,omitempty" gorm:"foreignKey:CreatedByID"`
	LastSeenAt    time.Time      `json:"lastSeenAt,omitempty"`
	Mobile        string         `json:"mobile" gorm:"unique" validate:"numeric"` // todo: required if no email
	Notifications []Notification `json:"notifications,omitempty"`
	Password      string         `json:"password,omitempty"`
	Photo         string         `json:"photo,omitempty"`
	Recovery      string         `json:"recovery,omitempty"` // todo validate:"numeric,len=6"
	Scopes        string         `json:"scopes"`
}

func (*User) AuthType

func (u *User) AuthType() string

func (*User) FullName

func (u *User) FullName() string

func (*User) Is

func (u *User) Is(role string) bool

func (*User) IsBasic

func (u *User) IsBasic() bool

type UserDTO

type UserDTO struct {
	ID           uint      `json:"id"`
	Address      string    `json:"address,omitempty"`
	AuthID       string    `json:"authID,omitempty"`
	AuthProvider string    `json:"authProvider,omitempty"`
	CreatedAt    time.Time `json:"createdAt"`
	Dob          time.Time `json:"dob,omitempty"`
	Email        string    `json:"email,omitempty"`
	FirstName    string    `json:"firstName"`
	LastName     string    `json:"lastName"`
	LastSeenAt   time.Time `json:"lastSeenAt"`
	Mobile       string    `json:"mobile"`
	Photo        string    `json:"photo,omitempty"`
	Scopes       string    `json:"scopes"`
}

type ValidationError

type ValidationError struct {
	FailedField string
	Tag         string
	Value       string
}

func GetValidationErrors

func GetValidationErrors(srcErr error) []*ValidationError

func (*ValidationError) Error

func (e *ValidationError) Error() string

type Yaml

type Yaml Json

Jump to

Keyboard shortcuts

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