models

package
v0.0.0-...-215198b Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

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

Hash ...

func VerifyPassword

func VerifyPassword(hashedPassword, password string) error

VerifyPassword ///

Types

type Post

type Post struct {
	ID        uint64    `gorm:"primary_key;auto_increment" json:"id"`
	Title     string    `gorm:"size:255;not null;unique" json:"title"`
	Content   string    `gorm:"size:255;not null;" json:"content"`
	Author    User      `json:"author"`
	AuthorID  uint32    `gorm:"not null" json:"author_id"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

Post ...

func (*Post) DeleteAPost

func (p *Post) DeleteAPost(db *gorm.DB, pid uint64, uid uint32) (int64, error)

DeleteAPost ...

func (*Post) FindAllPost

func (p *Post) FindAllPost(db *gorm.DB) (*[]Post, error)

FindAllPost ...

func (*Post) FindPostByID

func (p *Post) FindPostByID(db *gorm.DB, pid uint64) (*Post, error)

FindPostByID ...

func (*Post) Prepare

func (p *Post) Prepare()

Prepare ...

func (*Post) SavePost

func (p *Post) SavePost(db *gorm.DB) (*Post, error)

SavePost ...

func (*Post) UpdateAPost

func (p *Post) UpdateAPost(db *gorm.DB) (*Post, error)

UpdateAPost ...

func (*Post) Validate

func (p *Post) Validate() error

Validate ...

type User

type User struct {
	ID        uint32    `gorm:"primary_key;auto_increment" json:"id"`
	Nickname  string    `gorm:"size:255;not null;unique" json:"nickname"`
	Email     string    `gorm:"size:100;not null;unique" json:"email"`
	Password  string    `gorm:"size:100;not null;" json:"password"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

User ...

func (*User) BeforeSave

func (u *User) BeforeSave() error

BeforeSave ...

func (*User) DeleteAUser

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

DeleteAUser ...

func (*User) FindAUser

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

FindAUser ...

func (*User) FindAllUser

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

FindAllUser ...

func (*User) FindUserByID

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

FindUserByID ...

func (*User) Prepare

func (u *User) Prepare()

Prepare ...

func (*User) SaveUser

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

SaveUser ...

func (*User) UpdateAUser

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

UpdateAUser ...

func (*User) Validate

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

Validate ...

Jump to

Keyboard shortcuts

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