model

package
v0.0.0-...-b5fa30d Latest Latest
Warning

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

Go to latest
Published: May 29, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cache

func Cache(db *gorm.DB) *orm.CacheDB

func CacheStore

func CacheStore() cache.CacheStore

func DB

func DB() *gorm.DB

func GenerateAnonymousUser

func GenerateAnonymousUser() auth.User

GetAnonymousUser should generate an anonymous user model for all sessions. This should be an unauthenticated 0 value struct.

Types

type Post

type Post struct {
	Id        uint64    `json:"id,omitempty"`
	UserId    uint64    `form:"user_id" json:"user_id,omitempty"`
	Title     string    `form:"title" json:"title,omitempty"`
	Context   string    `form:"context" json:"context,omitempty"`
	CreatedAt time.Time `gorm:"column:created_time" json:"created_time,omitempty"`
	UpdatedAt time.Time `gorm:"column:updated_time" json:"updated_time,omitempty"`

	User User `gorm:"ForeignKey:UserId;AssociationForeignKey:Id" json:"user"`
}

func (*Post) GetPostById

func (p *Post) GetPostById(id uint64) *Post

func (*Post) GetUserPostsByUserId

func (p *Post) GetUserPostsByUserId(userId uint64, page int, size int) *[]Post

func (*Post) PostSave

func (p *Post) PostSave()

func (Post) TableName

func (p Post) TableName() string

type User

type User struct {
	orm.Model `gorm:"-"`

	Id        uint64    `json:"id,omitempty"`
	Nickname  string    `form:"nickname" json:"nickname,omitempty"`
	Password  string    `form:"password" json:"-"`
	Gender    int64     `json:"gender,omitempty"`
	Birthday  time.Time `json:"birthday,omitempty"`
	CreatedAt time.Time `gorm:"column:created_time" json:"created_time,omitempty"`
	UpdatedAt time.Time `gorm:"column:updated_time" json:"updated_time,omitempty"`
	// contains filtered or unexported fields
}

func (*User) AddUserWithNicknamePwd

func (u *User) AddUserWithNicknamePwd(nickname string, pwd string) *User

func (*User) GetById

func (u *User) GetById(id interface{}) error

GetById will populate a user object from a database model with a matching id.

func (*User) GetUserById

func (u *User) GetUserById(id uint64) *User

func (*User) GetUserByNicknamePwd

func (u *User) GetUserByNicknamePwd(nickname string, pwd string) *User

func (*User) IsAuthenticated

func (u *User) IsAuthenticated() bool

func (*User) Login

func (u *User) Login()

Login will preform any actions that are required to make a user model officially authenticated.

func (*User) Logout

func (u *User) Logout()

Logout will preform any actions that are required to completely logout a user.

func (User) TableName

func (u User) TableName() string

func (*User) TraceGetUserById

func (u *User) TraceGetUserById(id uint64) *User

func (*User) UniqueId

func (u *User) UniqueId() interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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