user

package
v0.1.23 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUserNameInvalide = errors.New("用户名名称已经被使用")
View Source
var Source = new(source)

Functions

func AddRoleForUser

func AddRoleForUser(user *User) error

AddRoleForUser add roles for user

func ChangeAvatar

func ChangeAvatar(ctx iris.Context)

ChangeAvatar 修改头像

func CleanToken

func CleanToken(authorityType int, userId string) error

CleanToken 清空 token

func Clear

func Clear(ctx iris.Context)

Clear 清空 token

func Create

func Create(req *Request) (uint, error)

func CreateUser

func CreateUser(ctx iris.Context)

CreateUser 添加

func DelToken

func DelToken(token string) error

DelToken 删除token

func DeleteUser

func DeleteUser(ctx iris.Context)

DeleteUser 删除

func GetAll

func GetAll(ctx iris.Context)

GetAll 分页列表

func GetMigration

func GetMigration() *gormigrate.Migration

func GetUser

func GetUser(ctx iris.Context)

GetUser 详情

func IsAdminUser

func IsAdminUser(id uint) error

func Logout

func Logout(ctx iris.Context)

Logout 退出

func Party

func Party() func(index iris.Party)

Party 用户

func Profile

func Profile(ctx iris.Context)

Profile 个人信息

func UpdateAvatar

func UpdateAvatar(db *gorm.DB, id uint, avatar string) error

func UpdateUser

func UpdateUser(ctx iris.Context)

UpdateUser 更新

func UserNameScope

func UserNameScope(username string) func(db *gorm.DB) *gorm.DB

UserNameScope 根据 username 查询 - username 名称

Types

type Avatar

type Avatar struct {
	Avatar string `json:"avatar"`
}

type BaseUser

type BaseUser struct {
	Name     string `gorm:"index;not null; type:varchar(60)" json:"name"`
	Username string `gorm:"uniqueIndex;not null;type:varchar(60)" json:"username" validate:"required"`
	Intro    string `gorm:"not null; type:varchar(512)" json:"intro"`
	Avatar   string `gorm:"type:varchar(1024)" json:"avatar"`
}

type LoginResponse

type LoginResponse struct {
	orm.ReqId
	Password     string   `json:"password"`
	AuthorityIds []string `gorm:"-" json:"authorityIds"`
}

func FindPasswordByUserName

func FindPasswordByUserName(db *gorm.DB, username string, scopes ...func(db *gorm.DB) *gorm.DB) (*LoginResponse, error)

type PageResponse

type PageResponse struct {
	Item []*Response
}

Paginate 分页

func (*PageResponse) Find

func (res *PageResponse) Find(db *gorm.DB, scopes ...func(db *gorm.DB) *gorm.DB) error

func (*PageResponse) Paginate

func (res *PageResponse) Paginate(db *gorm.DB, pageScope func(db *gorm.DB) *gorm.DB, scopes ...func(db *gorm.DB) *gorm.DB) (int64, error)

type ReqPaginate

type ReqPaginate struct {
	orm.Paginate
	Name string `json:"name"`
}

type Request

type Request struct {
	BaseUser
	Password  string   `json:"password"`
	RoleNames []string `json:"role_ids"`
}

func GetSources

func GetSources() ([]*Request, error)

func (*Request) Request

func (req *Request) Request(ctx iris.Context) error

type Response

type Response struct {
	orm.Model
	BaseUser
	Roles []string `gorm:"-" json:"roles"`
}

func FindById

func FindById(db *gorm.DB, id uint) (Response, error)

func FindByUserName

func FindByUserName(scopes ...func(db *gorm.DB) *gorm.DB) (*Response, error)

FindByName

func (*Response) First

func (res *Response) First(db *gorm.DB, scopes ...func(db *gorm.DB) *gorm.DB) error

func (*Response) ToString

func (res *Response) ToString()

type User

type User struct {
	gorm.Model
	BaseUser
	Password  string   `gorm:"type:varchar(250)" json:"password" validate:"required"`
	RoleNames []string `gorm:"-" json:"role_names"`
}

func (*User) Create

func (item *User) Create(db *gorm.DB) (uint, error)

Create 添加

func (*User) Delete

func (item *User) Delete(db *gorm.DB, scopes ...func(db *gorm.DB) *gorm.DB) error

Delete 删除

func (*User) Update

func (item *User) Update(db *gorm.DB, scopes ...func(db *gorm.DB) *gorm.DB) error

Update 更新

Jump to

Keyboard shortcuts

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