admin

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: Apache-2.0 Imports: 22 Imported by: 2

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(admin *Admin) error

AddRoleForUser add roles for user

func ChangeAvatar

func ChangeAvatar(ctx *gin.Context)

ChangeAvatar 修改头像

func Create

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

func CreateAdmin

func CreateAdmin(ctx *gin.Context)

CreateAdmin添加

func DeleteAdmin

func DeleteAdmin(ctx *gin.Context)

DeleteAdmin 删除

func GetAdmin

func GetAdmin(ctx *gin.Context)

GetAdmin 详情

func GetAll

func GetAll(ctx *gin.Context)

GetAll 分页列表

func GetMigration

func GetMigration() *gormigrate.Migration

func Group

func Group(group *gin.RouterGroup)

func IsAdminUser

func IsAdminUser(id uint) error

func Profile

func Profile(ctx *gin.Context)

Profile 个人信息

func UpdateAdmin

func UpdateAdmin(ctx *gin.Context)

UpdateAdmin 更新

func UpdateAvatar

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

func UserNameScope

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

UserNameScope 根据 username 查询 - username 名称

Types

type Admin

type Admin struct {
	gorm.Model
	BaseAdmin
	Password     string   `json:"-"  gorm:"not null;type:varchar(128);comment:用户登录密码"`
	AuthorityIds []string `json:"authorityIds" gorm:"-"`
}

func (*Admin) Create

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

Create 添加

func (*Admin) Delete

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

Delete 删除

func (*Admin) Update

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

Update 更新

type Avatar

type Avatar struct {
	HeaderImg string `json:"headerImg" gorm:"default:http://qmplusimg.henrongyi.top/head.png;comment:用户头像" form:"headerImg"`
}

type BaseAdmin

type BaseAdmin struct {
	Username string `json:"username" gorm:"not null;type:varchar(32);comment:用户登录名"`
	Status   int    `gorm:"column:status;type:tinyint(1);not null;default:1" json:"status"`  // 账号冻结 1为正常,2为禁止
	IsShow   int    `gorm:"column:is_show;type:tinyint(1);not null;default:1" json:"isShow"` // 是否显示 1为正常,2为禁止
	Email    string `json:"email" gorm:"default:'';comment:员工邮箱"`
	Phone    string `json:"phone" gorm:"type:char(15);default:'';comment:员工手机号" `
	NickName string `json:"nickName" gorm:"type:varchar(16);default:'员工姓名';comment:员工姓名" `
	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 {
	BaseAdmin
	Password       string   `json:"password"`
	AuthorityUuids []string `json:"authorityIds"`
}

func GetSources

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

func (*Request) Request

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

type Response

type Response struct {
	orm.Model
	BaseAdmin
	Authorities []string `gorm:"-" json:"authorities"`
}

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()

Jump to

Keyboard shortcuts

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