models

package
v0.0.0-...-4e54643 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: BSD-3-Clause Imports: 7 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 Article

type Article struct {
	ID        uint32    `gorm:"primary_key;auto_increment;" json:"id"`
	Slug      string    `gorm:"size:255;not null;unique" json:"slug"`
	SubHeader string    `gorm:"type:longtext;not null;" json:"sub_header"`
	Title     string    `gorm:"size:255;not null;unique" json:"title"`
	Body      string    `gorm:"type:longtext;not null" json:"body"`
	Category  string    `gorm:"size:255;not null" json:"category"`
	Tags      string    `json:"tags"`
	AuthorID  uint32    `gorm:"not null;" json:"author_id,omitempty"`
	CreatedAt time.Time `gorm:"not null;" json:"created_at"`
	UpdatedAt time.Time `gorm:"not null;" json:"updated_at"`
}

func (*Article) CreateArticle

func (a *Article) CreateArticle(db *gorm.DB) (*Article, error)

func (*Article) DeleteArticle

func (a *Article) DeleteArticle(db *gorm.DB, aid uint32) (int64, error)

func (Article) GetAllArticles

func (a Article) GetAllArticles(db *gorm.DB) ([]Article, error)

func (Article) GetArticleByID

func (a Article) GetArticleByID(db *gorm.DB, id uint32) (*Article, error)

func (Article) GetArticleBySlug

func (a Article) GetArticleBySlug(db *gorm.DB, slug string) (*Article, error)

func (*Article) Prepare

func (a *Article) Prepare()

func (Article) UpdateArticle

func (a Article) UpdateArticle(db *gorm.DB, aid uint32) (Article, error)

func (*Article) Validate

func (a *Article) Validate() error

type User

type User struct {
	ID        uint32    `gorm:"primary_key;auto_increment" json:"id"`
	Username  string    `gorm:"size:255;not null;unique" json:"username"`
	Name      string    `gorm:"size:255;" json:"name"`
	Email     string    `gorm:"size:255;not null;unique" json:"email,omitempty"`
	ShowEmail bool      `gorm:"default:false;not null;" json:"-"`
	Password  string    `gorm:"size:100;not null;" json:"password,omitempty"`
	Role      string    `gorm:"size:100;not null;" json:"role"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

func (*User) CreateUser

func (u *User) CreateUser(db *gorm.DB) (*User, error)

func (*User) DeleteUserByID

func (u *User) DeleteUserByID(db *gorm.DB, uid uint32) (int64, error)

func (*User) GetAllUsers

func (u *User) GetAllUsers(db *gorm.DB) (*[]User, error)

func (*User) GetUserByID

func (u *User) GetUserByID(db *gorm.DB, uid uint32) (*User, error)

func (*User) Prepare

func (u *User) Prepare()

func (*User) UpdateUser

func (u *User) UpdateUser(db *gorm.DB, 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