models

package
v0.0.0-...-bf4c602 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(password string) ([]byte, error)

func VerifyPassword

func VerifyPassword(hashedPassword, password string) error

Types

type BaseModel

type BaseModel struct {
	ID        uint64 `gorm:"primary_key;auto_increment" json:"id"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

BaseModel is used by other models to have default columns

type Profile

type Profile struct {
	BaseModel
	Title     string `gorm:"size:255;not null;unique" json:"title"`
	FirstName string `gorm:"size:255;not null;" json:"first_name"`
	LastName  string `gorm:"size:255;not null;" json:"last_name"`
	UserID    uint64 `gorm:"not null" json:"user_id"`
	User      User
}

type ResourceOperation

type ResourceOperation struct {
	BaseModel
	Path        string  `gorm:"size:1024;not null;index" json:"path"`
	HTTPMethod  string  `gorm:"size:10;not null;index" json:"http_method"`
	Role        []*Role `gorm:"many2many:role_resourcesoperations;"`
	Description string  `gorm:"size:2048;not null;index" json:"description"`
}

func (*ResourceOperation) FindByMethodAndPath

func (r *ResourceOperation) FindByMethodAndPath(method, path string) (*ResourceOperation, error)

func (*ResourceOperation) Prepare

func (r *ResourceOperation) Prepare()

func (*ResourceOperation) Save

func (*ResourceOperation) Update

func (r *ResourceOperation) Update(uid uint64) (*ResourceOperation, error)

func (*ResourceOperation) Upsert

func (r *ResourceOperation) Upsert() (*ResourceOperation, error)

type Role

type Role struct {
	BaseModel
	Name              string              `gorm:"size:100;not null;unique" json:"name"`
	ResourceOperation []ResourceOperation `gorm:"many2many:role_resourcesoperations;"`
}

type User

type User struct {
	BaseModel
	Email    string `gorm:"size:100;not null;unique" json:"email"`
	Mobile   string `gorm:"size:13;unique" json:"mobile"`
	Password string `gorm:"size:100;not null;" json:"password"`
	Nickname string `gorm:"size:100" json:"nickname"`
	RoleID   uint64 `gorm:"null" json:"role_id"`
	Role     Role
	Profile  *Profile
}

func (*User) BeforeSave

func (u *User) BeforeSave() error

func (*User) DeleteAUser

func (u *User) DeleteAUser(uid uint32) (int64, error)

func (*User) FindAllUsers

func (u *User) FindAllUsers() (*[]User, error)

func (*User) FindUserByID

func (u *User) FindUserByID(uid uint32) (*User, error)

func (*User) Login

func (u *User) Login() error

func (*User) Prepare

func (u *User) Prepare()

func (*User) SaveUser

func (u *User) SaveUser() (*User, error)

func (*User) UpdateAUser

func (u *User) UpdateAUser(uid uint32) (*User, error)

func (*User) Validate

func (u *User) Validate(action string) error

Jump to

Keyboard shortcuts

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