model

package
v0.0.0-...-0397089 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID          uint       `gorm:"primary_key" json:"id"`
	Name        string     `json:"name"`
	Password    string     `json:"-"`
	AuthorityID uint       `json:"authority_id"`
	Authority   *Authority `json:"authority"`
}

Account defines struct of account data.

func NewAccount

func NewAccount(name string, password string, authority *Authority) *Account

NewAccount is constructor.

func NewAccountWithPlainPassword

func NewAccountWithPlainPassword(name string, password string, authority *Authority) *Account

NewAccountWithPlainPassword is constructor. And it is encoded plain text password by using bcrypt.

func (*Account) Create

func (a *Account) Create(rep *repository.Repository) (*Account, error)

Create persists this account data.

func (*Account) FindByName

func (a *Account) FindByName(rep *repository.Repository, name string) (*Account, error)

FindByName returns accounts full matched given account name.

func (Account) TableName

func (Account) TableName() string

TableName returns the table name of account struct and it is used by gorm.

func (*Account) ToString

func (a *Account) ToString() (string, error)

ToString is return string of object

type Authority

type Authority struct {
	ID   uint   `gorm:"primary_key" json:"id"`
	Name string `json:"name"`
}

Authority defines struct of authority data.

func NewAuthority

func NewAuthority(name string) *Authority

NewAuthority is constructor.

func (*Authority) Create

func (a *Authority) Create(rep *repository.Repository) (*Authority, error)

Create persists this authority data.

func (Authority) TableName

func (Authority) TableName() string

TableName returns the table name of authority struct and it is used by gorm.

func (*Authority) ToString

func (a *Authority) ToString() (string, error)

ToString is return string of object

Jump to

Keyboard shortcuts

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