Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Models = []interface{}{ &User{}, &UserToken{}, &LoginHistory{}, &Article{}, &Comment{}, &ScoreHistory{}, &PaymentHistory{}, &CommentArchive{}, &Admin{}, }
Functions ¶
func GeneratePassword ¶
GeneratePassword will generate a hashed password for us based on the user's input.
Types ¶
type Article ¶
type Article struct { Id int64 `json:"id" form:"id"` Title string `json:"title" form:"title"` Content string `json:"content" form:"content"` CreateAt int64 `json:"create_at" form:"create_at"` UpdateAt int64 `json:"update_at" form:"update_at"` UserId int64 `json:"user_id" form:"user_id"` Category string `json:"category" form:"category"` TagsString datatypes.JSON `json:"tags_string" form:"tags_string"` ViewTimes int64 `json:"view_times" form:"view_times"` Likes int64 `json:"likes" form:"likes"` Dislikes int64 `json:"dislikes" form:"dislikes"` }
type CommentArchive ¶
type LoginHistory ¶
type PaymentHistory ¶
type ScoreHistory ¶
type ScoreHistory struct { ID int64 `json:"id" form:"id"` ChangeScore int64 `json:"change_score" form:"change_score"` UserId int64 `json:"user_id" form:"user_id"` CreateAt int64 `json:"create_at" form:"create_at"` UpdateAt int64 `json:"update_at" form:"update_at"` }
ScoreHistory score history table
type User ¶
type User struct { ID int64 `json:"id" form:"id"` Name string `json:"name" form:"name"` Email string Avatar string `json:"avatar" form:"avatar"` EmailVerifiedAt time.Time Password string RememberToken string CreatedAt time.Time `json:"created_at" form:"created_at"` UpdateAt time.Time }
User is our User example model. Keep note that the tags for public-use (for our web app) should be kept in other file like "web/viewmodels/user.go" which could wrap by embedding the datamodels.User or define completely new fields instead but for the shake of the example, we will use this datamodel as the only one User model in our application.
type UserToken ¶
type UserToken struct { ID int64 `json:"id" form:"id"` Token string `gorm:"size:32;unique;not null" json:"token" form:"token"` UserId int64 `gorm:"not null;index:idx_user_id;" json:"userId" form:"userId"` ExpiredAt int64 `gorm:"not null" json:"expiredAt" form:"expiredAt"` Status int `gorm:"not null;index:idx_status" json:"status" form:"status"` CreateTime int64 `gorm:"not null" json:"createTime" form:"createTime"` }
User is our User example model. Keep note that the tags for public-use (for our web app) should be kept in other file like "web/viewmodels/user.go" which could wrap by embedding the datamodels.User or define completely new fields instead but for the shake of the example, we will use this datamodel as the only one User model in our application.