Documentation
¶
Index ¶
- Constants
- func GetDB() (*gorm.DB, error)
- func GetUserDB() (*gorm.DB, error)
- func Init()
- func WhereBuild(where map[string]interface{}) (whereSQL string, vals []interface{}, err error)
- type NullType
- type Token
- type UserBaseModel
- type UserFansModel
- type UserFollow
- type UserFollowModel
- type UserInfo
- type UserList
- type UserStatModel
Constants ¶
View Source
const ( // DefaultDatabase default database DefaultDatabase = "default" // UserDatabase user database UserDatabase = "user" )
Variables ¶
This section is empty.
Functions ¶
func WhereBuild ¶
WhereBuild sql build where see: https://github.com/jinzhu/gorm/issues/2055
Types ¶
type NullType ¶
type NullType byte
NullType 空字节类型
const ( // IsNull the same as `is null` IsNull NullType // IsNotNull the same as `is not null` IsNotNull )
type UserBaseModel ¶
type UserBaseModel struct {
ID uint64 `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"id"`
Username string `json:"username" gorm:"column:username;not null" binding:"required" validate:"min=1,max=32"`
Password string `json:"password" gorm:"column:password;not null" binding:"required" validate:"min=5,max=128"`
Phone int64 `gorm:"column:phone" json:"phone"`
Email string `gorm:"column:email" json:"email"`
Avatar string `gorm:"column:avatar" json:"avatar"`
Sex int `gorm:"column:sex" json:"sex"`
CreatedAt time.Time `gorm:"column:created_at" json:"-"`
UpdatedAt time.Time `gorm:"column:updated_at" json:"-"`
}
UserBaseModel User represents a registered user.
type UserFansModel ¶
type UserFansModel struct {
ID uint64 `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"-"`
FollowerUID uint64 `gorm:"column:follower_uid" json:"follower_uid"`
Status int `gorm:"column:status" json:"status"`
UserID uint64 `gorm:"column:user_id" json:"user_id"`
CreatedAt time.Time `gorm:"column:created_at" json:"-"`
UpdatedAt time.Time `gorm:"column:updated_at" json:"-"`
}
UserFansModel 粉丝表
func (*UserFansModel) TableName ¶
func (u *UserFansModel) TableName() string
TableName sets the insert table name for this struct type
type UserFollow ¶
type UserFollow struct {
FollowNum int `json:"follow_num"` // 关注数
FansNum int `json:"fans_num"` // 粉丝数
IsFollow int `json:"is_follow"` // 是否关注 1:是 0:否
IsFans int `json:"is_fans"` // 是否是粉丝 1:是 0:否
}
UserFollow 关注
type UserFollowModel ¶
type UserFollowModel struct {
ID uint64 `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"-"`
FollowedUID uint64 `gorm:"column:followed_uid" json:"followed_uid"`
Status int `gorm:"column:status" json:"status"`
UserID uint64 `gorm:"column:user_id" json:"user_id"`
CreatedAt time.Time `gorm:"column:created_at" json:"-"`
UpdatedAt time.Time `gorm:"column:updated_at" json:"-"`
}
UserFollowModel 关注表
func (*UserFollowModel) TableName ¶
func (u *UserFollowModel) TableName() string
TableName sets the insert table name for this struct type
type UserInfo ¶
type UserInfo struct {
ID uint64 `json:"id" example:"1"`
Username string `json:"username" example:"张三"`
Avatar string `json:"avatar"`
Sex int `json:"sex"`
UserFollow *UserFollow `json:"user_follow"`
}
UserInfo 对外暴露的结构体
type UserStatModel ¶
type UserStatModel struct {
ID uint64 `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"-"`
UserID uint64 `gorm:"column:user_id;not null" json:"user_id" binding:"required"`
FollowCount int `gorm:"column:follow_count" json:"follow_count"`
FollowerCount int `gorm:"column:follower_count" json:"follower_count"`
Status int `gorm:"column:status" json:"status"`
CreatedAt time.Time `gorm:"column:created_at" json:"-"`
UpdatedAt time.Time `gorm:"column:updated_at" json:"-"`
}
UserStatModel 用户数据统计表
Click to show internal directories.
Click to hide internal directories.