model

package
v0.0.0-...-4b55cb2 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(ctx context.Context, db *gorm.DB) (bool, error)

Check 检查数据是否存在

func ExecTrans

func ExecTrans(ctx context.Context, db *gorm.DB, fn TransFunc) error

ExecTrans 执行事务

func ExecTransWithLock

func ExecTransWithLock(ctx context.Context, db *gorm.DB, fn TransFunc) error

ExecTransWithLock 执行事务(加锁)

func FindOne

func FindOne(ctx context.Context, db *gorm.DB, out interface{}) (bool, error)

FindOne 查询单条数据

func FindPage

func FindPage(ctx context.Context, db *gorm.DB, pp dao.PaginationParam, out interface{}) (int, error)

FindPage 查询分页数据

func ParseOrder

func ParseOrder(items []*dao.OrderField, handle ...OrderFieldFunc) string

ParseOrder 解析排序字段

func WrapPageQuery

func WrapPageQuery(ctx context.Context, db *gorm.DB, pp dao.PaginationParam, out interface{}) (*dao.PaginationResult, error)

WrapPageQuery 包装带有分页的查询

Types

type Login

type Login struct {
	Auth      auth.Auther
	UserModel model.IUser
}

Login 登录管理

func NewLogin

func NewLogin(auth auth.Auther, userModel model.IUser) *Login

func (*Login) DestroyToken

func (a *Login) DestroyToken(ctx context.Context, tokenString string) error

DestroyToken 销毁令牌

func (*Login) GenerateToken

func (a *Login) GenerateToken(ctx context.Context, userID string) (*stypes.LoginTokenInfo, error)

GenerateToken 生成令牌

func (*Login) GetCaptcha

func (a *Login) GetCaptcha(ctx context.Context, length int) (*stypes.LoginCaptcha, error)

GetCaptcha 获取图形验证码信息

func (*Login) GetLoginInfo

func (a *Login) GetLoginInfo(ctx context.Context, userID string) (*stypes.UserLoginInfo, error)

GetLoginInfo 获取当前用户登录信息

func (*Login) ResCaptcha

func (a *Login) ResCaptcha(ctx context.Context, w http.ResponseWriter, captchaID string, width, height int) error

ResCaptcha 生成并响应图形验证码

func (*Login) UpdatePassword

func (a *Login) UpdatePassword(ctx context.Context, userID string, params stypes.UpdatePasswordParam) error

UpdatePassword 更新当前用户登录密码

func (*Login) Verify

func (a *Login) Verify(ctx context.Context, userName, password string) (*stypes.User, error)

Verify 登录验证

type OrderFieldFunc

type OrderFieldFunc func(string) string

OrderFieldFunc 排序字段转换函数

type Trans

type Trans struct {
	DB *gorm.DB
}

Trans 事务管理

func (*Trans) Exec

func (t *Trans) Exec(ctx context.Context, fn func(context.Context) error) error

Exec 执行事务

type TransFunc

type TransFunc func(context.Context) error

TransFunc 定义事务执行函数

type User

type User struct {
	DB *gorm.DB
}

User 用户存储

func NewUser

func NewUser(db *gorm.DB) *User

func (*User) Create

func (u *User) Create(ctx context.Context, item types2.User) error

Create 创建数据

func (*User) Delete

func (u *User) Delete(ctx context.Context, recordID string) error

Delete 删除数据

func (*User) Get

func (u *User) Get(ctx context.Context, recordID string, opts ...types2.UserQueryOptions) (*types2.User, error)

Get 查询指定数据

func (*User) Query

Query 查询数据

func (*User) Update

func (u *User) Update(ctx context.Context, recordID string, item types2.User) error

Update 更新数据

func (*User) UpdatePassword

func (u *User) UpdatePassword(ctx context.Context, recordID, password string) error

UpdatePassword 更新密码

func (*User) UpdateStatus

func (u *User) UpdateStatus(ctx context.Context, recordID string, status int) error

UpdateStatus 更新状态

Jump to

Keyboard shortcuts

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