user

package
v0.0.0-...-6e4d488 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

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 CheckingCode

func CheckingCode(ctx iris.Context)

验证手机验证码

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 CreateNoPassUser

func CreateNoPassUser(ctx iris.Context)

CreateNoPassUser 添加

func CreateNoPassUuid

func CreateNoPassUuid(req *RequestNpUser) (string, error)

func CreateUser

func CreateUser(ctx iris.Context)

CreateUser 添加

func CreateUuid

func CreateUuid(req *RequestUser) (string, error)

func DelToken

func DelToken(token string) error

DelToken 删除token

func DeleteUser

func DeleteUser(ctx iris.Context)

DeleteUser 删除

func GetAccessToken

func GetAccessToken(req *RequestUser) (string, error)

GetAccessToken 登录

func GetAll

func GetAll(ctx iris.Context)

GetAll 分页列表

func GetUser

func GetUser(ctx iris.Context)

GetUser 详情

func IdScope

func IdScope(id string) func(db *gorm.DB) *gorm.DB

- id 用户id

func IsAdminUser

func IsAdminUser(id uint) error

func IsNpReg

func IsNpReg(req *RequestNpUser) (string, error)

func IsReg

func IsReg(req *RequestUser) (string, error)

func Logout

func Logout(ctx iris.Context)

Logout 退出

func MobileScope

func MobileScope(mobile string) func(db *gorm.DB) *gorm.DB

- mobile 手机

func Party

func Party() module.WebModule

Party 用户

func Profile

func Profile(ctx iris.Context)

Profile 个人信息

func PubParty

func PubParty() module.WebModule

无须认证注册用户

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 名称

func UserStructLevelValidation

func UserStructLevelValidation(sl validator.StructLevel)

Types

type Avatar

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

type BaseUser

type BaseUser struct {
	Uuid     string `gorm:"type:varchar(36);" json:"uuid"`
	Sex      string `gorm:"default:'0';not null; type:tinyint(1)" json:"sex"`
	Age      string `gorm:"default:'0';not null; type:tinyint(2)" json:"age"`
	Region   string `gorm:"not null; type:varchar(15)" json:"region"`
	Mobile   string `gorm:"not null; type:varchar(20)" json:"mobile" validate:"required"`
	Nickname string `gorm:"not null; type:varchar(60)" json:"nickname"`
	Name     string `gorm:"index;not null; type:varchar(60)" json:"name"`
	Username string `gorm:"uniqueIndex;not null;type:varchar(60)" json:"username"`
	Identity string `gorm:"not null; type:varchar(30)" json:"identity"`
	Intro    string `gorm:"not null; type:varchar(512)" json:"intro"`
	Avatar   string `gorm:"type:varchar(1024)" json:"avatar"`
}

type CheckCode

type CheckCode struct {
	Code   string `json:"code" validate:"required"`
	Mobile string `gorm:"not null; type:varchar(20)" json:"mobile" validate:"required"`
}

type LoginResponse

type LoginResponse struct {
	g.ReqId
	Password string `json:"password"`
	Uuid     string `gorm:"type:varchar(36);" json:"uuid"`
	NickName string `gorm:"type:varchar(60)" json:"nickname"`
	Name     string `gorm:"type:varchar(60)" json:"name"`
}

func FindPasswordByUserName

func FindPasswordByUserName(db *gorm.DB, mobile string, ids ...uint) (LoginResponse, error)

type PageResponse

type PageResponse []*Response

Paginate 分页

func (*PageResponse) Paginate

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

type ReqPaginate

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

type Request

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

func GetSources

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

func (*Request) Request

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

type RequestNpUser

type RequestNpUser struct {
	BaseUser
	Code    string `json:"code" validate:"required"`
	RoleIds []uint `json:"role_ids"`
}

func (*RequestNpUser) RequestNpUser

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

type RequestUser

type RequestUser struct {
	BaseUser
	Code     string `json:"code" validate:"required"`
	Password string `json:"password" validate:"required"`
	RoleIds  []uint `json:"role_ids"`
}

func (*RequestUser) RequestUser

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

type Response

type Response struct {
	g.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"`
	RoleIds  []uint `gorm:"-" json:"role_ids"`
}

func (*User) Create

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

Create 添加

func (*User) CreateUuid

func (item *User) CreateUuid(db *gorm.DB) (string, error)

CreateUuid 添加

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 更新

func (*User) UpdatePw

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

UpdatePw 更新

type UserNp

type UserNp struct {
	gorm.Model
	BaseUser
}

func (*UserNp) CreateUuid

func (item *UserNp) CreateUuid(db *gorm.DB) (string, error)

CreateUuid 添加

func (*UserNp) TableName

func (m *UserNp) TableName() string

表GORM模型的名称

func (*UserNp) UpdatePw

func (item *UserNp) UpdatePw(db *gorm.DB, scopes ...func(db *gorm.DB) *gorm.DB) error

UpdatePw 更新

Jump to

Keyboard shortcuts

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