role

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: 16 Imported by: 0

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(id uint, perms casbin.PermsCollection) 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 GetRoleIds

func GetRoleIds() ([]uint, 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() module.WebModule

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 []*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, 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 {
	BaseRole
	Perms casbin.PermsCollection `json:"perms"`
}

func GetSources

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

func (*Request) Request

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

type Response

type Response struct {
	g.Model
	BaseRole
}

func FindById

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

func FindByName

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

FindByName

func FindInId

func FindInId(db *gorm.DB, ids []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 casbin.PermsCollection `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