model

package
v0.0.0-...-618fe63 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// JWT variable instance of intef
	JWT intef = &wt{}
)
View Source
var (
	// Validator var
	Validator validate = &valid{}
)

Functions

This section is empty.

Types

type Bcrypt

type Bcrypt struct{}

Bcrypt struct

func (*Bcrypt) CheckPasswordHash

func (b *Bcrypt) CheckPasswordHash(password, hash string) bool

CheckPasswordHash func

func (*Bcrypt) HashPassword

func (b *Bcrypt) HashPassword(password string) (string, error)

HashPassword func

type DBLogger

type DBLogger struct {
	SlowThreshold         time.Duration
	SourceField           string
	SkipErrRecordNotFound bool
}

DBLogger struct

func NewDBLogger

func NewDBLogger() *DBLogger

NewDBLogger func

func (*DBLogger) Error

func (l *DBLogger) Error(ctx context.Context, s string, args ...interface{})

Error func

func (*DBLogger) Info

func (l *DBLogger) Info(ctx context.Context, s string, args ...interface{})

Info func

func (*DBLogger) LogMode

LogMode func

func (*DBLogger) Trace

func (l *DBLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

Trace func

func (*DBLogger) Warn

func (l *DBLogger) Warn(ctx context.Context, s string, args ...interface{})

Warn func

type Data

type Data struct {
	User
	Token string `json:"token"`
}

Data struct

type Media

type Media struct {
	ID          uint64    `json:"-" gorm:"primaryKey"`
	URL         string    `validate:"required" json:"url"`
	Type        string    `validate:"required" json:"type"`
	Title       *string   `validate:"required" json:"title"`
	Description *string   `validate:"required" json:"description"`
	CreatedAt   time.Time `json:"-"`
	UpdatedAt   time.Time `json:"-"`
}

Media struct

type Mediaables

type Mediaables struct {
	ID        uint64 `json:"-" gorm:"primaryKey"`
	MediaID   uint64 `json:"-"`
	OwnerID   uint64 `json:"-"`
	OwnerType string `json:"-"`
}

Mediaables struct

type Notification

type Notification struct {
	Data    Data   `json:"data"`
	Message string `json:"message"`
	KEY     string `json:"key"`
	Type    string `json:"type"`
}

Notification struct

type Permission

type Permission struct {
	ID        uint64    `json:"-" gorm:"primaryKey"`
	Name      string    `json:"name" gorm:"unique;not null;type:varchar(30);"`
	Role      []*Role   `json:"-" gorm:"many2many:roles_permissions;association_foreignkey:ID;foreignkey:ID"`
	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`
}

Permission struct

type Role

type Role struct {
	ID          uint64        `json:"-" gorm:"primaryKey"`
	Name        string        `json:"name" gorm:"unique;not null;type:varchar(30);"`
	Permissions []*Permission `json:"permissions" gorm:"many2many:roles_permissions;association_foreignkey:ID;foreignkey:ID"`
	CreatedAt   time.Time     `json:"-"`
	UpdatedAt   time.Time     `json:"-"`
}

Role struct

type User

type User struct {
	ID        uint64       `json:"id" gorm:"primaryKey"`
	Username  string       `validate:"required" json:"username,omitempty" gorm:"unique;not null;type:varchar(100);"`
	Password  *string      `validate:"required,gte=7" json:"-" gorm:"type:varchar(100);"`
	Name      string       `validate:"required" json:"name,omitempty" gorm:"type:varchar(100);"`
	LastName  string       `validate:"required" json:"last_name,omitempty" gorm:"type:varchar(100);"`
	Phone     string       `validate:"required" json:"phone,omitempty" gorm:"unique;not null;type:varchar(30);"`
	Email     string       `validate:"required,email" json:"email,omitempty" gorm:"unique;not null;type:varchar(60);"`
	Token     string       `json:"-"`
	RoleID    uint64       `json:"-"`
	Role      Role         `json:"role" gorm:"foreignKey:RoleID;references:ID"`
	Media     []Mediaables `json:"-" gorm:"polymorphic:Owner;"`
	CreatedAt time.Time    `json:"created_at"`
	UpdatedAt time.Time    `json:"-"`
}

User struct

Jump to

Keyboard shortcuts

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