role

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: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRoleNameInvalide = errors.New("角色名称已经被使用")
View Source
var Source = new(source)

Functions

func AddPermForRole

func AddPermForRole(name string, perms [][]string) error

AddPermForRole

func Create

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

Create 添加

func CreateRole

func CreateRole(ctx iris.Context)

CreateRole 添加

func DeleteRole

func DeleteRole(ctx iris.Context)

DeleteRole 删除

func First

func First(ctx iris.Context)

First 详情

func GetAdminRoleName

func GetAdminRoleName() string

GetAdminRoleName 获管理员角色名称

func GetAll

func GetAll(ctx iris.Context)

GetAll 分页列表

func GetMigration

func GetMigration() *gormigrate.Migration

func GetRoleNames added in v0.0.7

func GetRoleNames() ([]string, error)

func IsAdminRole

func IsAdminRole(id uint) error

func NameScope

func NameScope(name string) func(db *gorm.DB) *gorm.DB

NameScope 根据 name 查询 - name 名称

func Party

func Party() func(index iris.Party)

Party 角色模块

func UpdateRole

func UpdateRole(ctx iris.Context)

UpdateRole 更新

Types

type BaseRole

type BaseRole struct {
	Name        string `gorm:"uniqueIndex;not null; type:varchar(256)" json:"name" validate:"required,gte=4,lte=50" comment:"名称"`
	DisplayName string `gorm:"type:varchar(256)" json:"displayName" comment:"显示名称"`
	Description string `gorm:"type:varchar(256)" json:"description" comment:"描述"`
}

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 {
	BaseRole
	Perms [][]string `json:"perms"`
}

func GetSources

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

func (*Request) Request

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

type Response

type Response struct {
	orm.Model
	BaseRole
}

func FindByName

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

FindByName

func FindInId

func FindInId(db *gorm.DB, ids []uint) ([]*Response, error)

func FindInName added in v0.0.7

func FindInName(db *gorm.DB, names []string) ([]*Response, error)

func (*Response) First

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

type Role

type Role struct {
	gorm.Model
	BaseRole

	Perms [][]string `gorm:"-" json:"perms"`
}

func (*Role) Create

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

Create 添加

func (*Role) Delete

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

Delete 删除

func (*Role) Update

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

Update 更新

type RoleCollection

type RoleCollection []Request

Jump to

Keyboard shortcuts

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