models

package
v0.0.0-...-1bf86c4 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const UserTable = "users"

Variables

View Source
var NotExists = Base.LogicError("记录不存在")

Functions

This section is empty.

Types

type ModelWrapper

type ModelWrapper struct {
	Db            *gorm.DB
	ConnectorName string
	Conn          string
	Connector     starters.IDataBaseConnector
}

func (*ModelWrapper) Close

func (wrapper *ModelWrapper) Close()

func (*ModelWrapper) Connection

func (wrapper *ModelWrapper) Connection(name ...string) starters.IDataBaseConnector

func (*ModelWrapper) Destroy

func (wrapper *ModelWrapper) Destroy()

func (*ModelWrapper) GetOrm

func (wrapper *ModelWrapper) GetOrm() *gorm.DB

func (*ModelWrapper) SetOrm

func (wrapper *ModelWrapper) SetOrm(orm *gorm.DB) *ModelWrapper

type User

type User struct {
	ID        int64     `gorm:"primary_key,column:id;comment:'序号ID'" Tr:"id" json:"id"`
	Username  string    `gorm:"unique;column:username;not null;comment;'用户名'" sql:"index" Tr:"username" json:"username" `
	Mobile    string    `gorm:"column:mobile;comment:'手机号'" Tr:"mobile" json:"mobile"`
	Email     string    `gorm:"column:email;comment:'邮箱地址'" Tr:"email" json:"email"`
	Sex       string    `gorm:"column:sex;comment:'性别';default:'未知'" Tr:"sex" json:"sex" `
	Password  string    `gorm:"column:password;comment:'秘文密码';" Tr:"password" json:"password"`
	CreatedAt time.Time `gorm:"column:created_at;not null;comment:'创建时间';" Tr:"createdAt" json:"createdAt"`
	UpdatedAt time.Time `gorm:"unique;column:updated_at;null;comment:'更新时间';" Tr:"updatedAt" json:"updatedAt"`
	DeletedAt time.Time `gorm:"column:deleted_at;null;comment:'软删除时间';" sql:"index" Tr:"deletedAt" json:"deletedAt"`
}

func NewUser

func NewUser() *User

func (User) TableName

func (User) TableName() string

type UserWrapper

type UserWrapper struct {
	M *User
	ModelWrapper
}

func NewUserWrapper

func NewUserWrapper(u ...*User) *UserWrapper

func (*UserWrapper) Create

func (u *UserWrapper) Create(user User) int64

func (*UserWrapper) EncodePassword

func (u *UserWrapper) EncodePassword(password string) string

func (*UserWrapper) Exists

func (u *UserWrapper) Exists(user *User) bool

func (*UserWrapper) GetByEmail

func (u *UserWrapper) GetByEmail(email string) (*User, bool)

func (*UserWrapper) GetById

func (u *UserWrapper) GetById(id int64) (*User, error)

func (*UserWrapper) GetByKey

func (u *UserWrapper) GetByKey(key string, value interface{}) (*User, bool)

func (*UserWrapper) GetByMobile

func (u *UserWrapper) GetByMobile(mobile string) (*User, bool)

func (*UserWrapper) GetByUserName

func (u *UserWrapper) GetByUserName(name string) (*User, error)

func (*UserWrapper) GetModel

func (u *UserWrapper) GetModel() *User

func (*UserWrapper) GetPasswordByUserName

func (u *UserWrapper) GetPasswordByUserName(name string) (string, bool)

func (*UserWrapper) Lists

func (u *UserWrapper) Lists(conditions map[string]interface{}, result interface{}) error

func (*UserWrapper) Model

func (u *UserWrapper) Model() *User

func (*UserWrapper) Save

func (u *UserWrapper) Save(user *User, data map[string]interface{}) bool

func (*UserWrapper) Search

func (u *UserWrapper) Search(conditions map[string]interface{}, result interface{}) error

func (*UserWrapper) SetModel

func (u *UserWrapper) SetModel(user *User) *UserWrapper

func (*UserWrapper) Table

func (u *UserWrapper) Table() string

func (*UserWrapper) Update

func (u *UserWrapper) Update(user *User, update map[string]interface{}) bool

func (*UserWrapper) UpdatePassword

func (u *UserWrapper) UpdatePassword(id int64, password string) bool

func (*UserWrapper) VerifyPassword

func (u *UserWrapper) VerifyPassword(password string, pass2 string) bool

Jump to

Keyboard shortcuts

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