perm

package
v0.6.28 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: AGPL-3.0 Imports: 12 Imported by: 8

Documentation

Index

Constants

View Source
const (
	BehaviorValueTypeNumber  = `number`
	BehaviorValueTypeFloat64 = `float64`
	BehaviorValueTypeFloat   = `float`
	BehaviorValueTypeFloat32 = `float32`
	BehaviorValueTypeInt32   = `int32`
	BehaviorValueTypeInt     = `int`
	BehaviorValueTypeInt64   = `int64`
	BehaviorValueTypeUint32  = `uint32`
	BehaviorValueTypeUint    = `uint`
	BehaviorValueTypeUint64  = `uint64`
	BehaviorValueTypeBool    = `bool`
	BehaviorValueTypeString  = `string`
	BehaviorValueTypeList    = `list`
	BehaviorValueTypeJSON    = `json`
	BehaviorValueTypeSlice   = `slice`
)

Variables

This section is empty.

Functions

func BuildPermActions

func BuildPermActions(values []string) string

func HandleBatchCheck

func HandleBatchCheck(ctx echo.Context, config *echo.KVData, current string, rules map[string]string) (mp map[string]interface{}, err error)

func HandleCheck

func HandleCheck(ctx echo.Context, config *echo.KVData, current string, typ string, permission string, parsed interface{}) (interface{}, error)

func HandleFireRender

func HandleFireRender(ctx echo.Context, config *echo.KVData) (err error)

func HandleGenerate

func HandleGenerate(ctx echo.Context, config *echo.KVData) (mp map[string]string, err error)

func JSONBytesParseError

func JSONBytesParseError(err error, jsonBytes []byte) error

func SerializeBehaviorValues

func SerializeBehaviorValues(permBehaviors map[string][]string, behaviors *Behaviors) (string, error)

Types

type Behavior

type Behavior struct {
	Name          string      `json:",omitempty" xml:",omitempty"`
	ValueType     string      `json:",omitempty" xml:",omitempty"` // list / number / json
	VTypeOptions  echo.H      `json:",omitempty" xml:",omitempty"`
	Value         interface{} `json:",omitempty" xml:",omitempty"` // 在Behaviors中登记时,代表默认值;在BehaviorPerms中登记时代表针对某个用户设置的值
	FormHelpBlock interface{}
	// contains filtered or unexported fields
}

func NewBehavior

func NewBehavior(opts ...BehaviorOption) *Behavior

func (*Behavior) AsString

func (b *Behavior) AsString(value interface{}) string

func (Behavior) IsValid

func (b Behavior) IsValid() bool

func (*Behavior) SetFormHelpBlock

func (b *Behavior) SetFormHelpBlock(helpBlock interface{})

func (*Behavior) SetFormValueDecoder

func (b *Behavior) SetFormValueDecoder(parser func([]string) (interface{}, error))

func (*Behavior) SetFormValueEncoder

func (b *Behavior) SetFormValueEncoder(encoder func(interface{}) (string, error))

func (*Behavior) SetValueInitor

func (b *Behavior) SetValueInitor(initor func() interface{})

func (*Behavior) String

func (b *Behavior) String() string

type BehaviorOption

type BehaviorOption func(*Behavior)

func BehaviorOptFormHelpBlock

func BehaviorOptFormHelpBlock(helpBlock interface{}) BehaviorOption

func BehaviorOptFormValueDecoder

func BehaviorOptFormValueDecoder(parser func([]string) (interface{}, error)) BehaviorOption

func BehaviorOptFormValueEncoder

func BehaviorOptFormValueEncoder(encoder func(interface{}) (string, error)) BehaviorOption

func BehaviorOptName

func BehaviorOptName(name string) BehaviorOption

func BehaviorOptVTypeOption

func BehaviorOptVTypeOption(key string, value interface{}) BehaviorOption

func BehaviorOptVTypeOptions

func BehaviorOptVTypeOptions(opts echo.H) BehaviorOption

func BehaviorOptValue

func BehaviorOptValue(defaultValue interface{}) BehaviorOption

func BehaviorOptValueInitor

func BehaviorOptValueInitor(initor func() interface{}) BehaviorOption

func BehaviorOptValueType

func BehaviorOptValueType(vt string) BehaviorOption

type BehaviorPerms

type BehaviorPerms map[string]Behavior

func ParseBehavior

func ParseBehavior(permBehaviors string, behaviors *Behaviors) (BehaviorPerms, error)

func (BehaviorPerms) Add

func (b BehaviorPerms) Add(be *Behavior, value ...interface{})

func (BehaviorPerms) CheckBehavior

func (b BehaviorPerms) CheckBehavior(perm string) *CheckedBehavior

func (BehaviorPerms) Get

func (b BehaviorPerms) Get(name string) Behavior

type Behaviors

type Behaviors struct {
	*echo.KVData
}

func NewBehaviors

func NewBehaviors() *Behaviors

func (*Behaviors) Register

func (m *Behaviors) Register(key string, value string, options ...interface{})

type CheckedBehavior

type CheckedBehavior struct {
	Value   interface{}
	Checked bool
}

type Handle

type Handle struct {
	// contains filtered or unexported fields
}

func NewHandle

func NewHandle() *Handle

func (*Handle) Check

func (u *Handle) Check(ctx echo.Context, parsed interface{}, current string) (interface{}, error)

func (*Handle) FireRender

func (u *Handle) FireRender(ctx echo.Context) error

func (*Handle) Generate

func (u *Handle) Generate(ctx echo.Context) (string, error)

func (*Handle) IsValid

func (u *Handle) IsValid(ctx echo.Context) bool

func (*Handle) ListItems

func (u *Handle) ListItems(ctx echo.Context) ([]interface{}, error)

func (*Handle) OnRender

func (u *Handle) OnRender(fn func(ctx echo.Context) error) Handler

func (*Handle) Parse

func (u *Handle) Parse(ctx echo.Context, rule string) (interface{}, error)

func (*Handle) SetChecker

func (u *Handle) SetChecker(fn func(ctx echo.Context, parsed interface{}, current string) (interface{}, error)) Handler

func (*Handle) SetGenerator

func (u *Handle) SetGenerator(fn func(ctx echo.Context) (string, error)) Handler

func (*Handle) SetIsValid

func (u *Handle) SetIsValid(fn func(ctx echo.Context) bool) Handler

func (*Handle) SetItemLister

func (u *Handle) SetItemLister(fn func(ctx echo.Context) ([]interface{}, error)) Handler

func (*Handle) SetParser

func (u *Handle) SetParser(fn func(ctx echo.Context, rule string) (interface{}, error)) Handler

func (*Handle) SetTmpl

func (u *Handle) SetTmpl(tmpl string, typ ...string) Handler

func (*Handle) Tmpl

func (u *Handle) Tmpl(typ ...string) string

type Handler

type Handler interface {
	SetGenerator(fn func(ctx echo.Context) (string, error)) Handler
	SetChecker(fn func(ctx echo.Context, parsed interface{}, current string) (interface{}, error)) Handler
	SetParser(fn func(ctx echo.Context, rule string) (interface{}, error)) Handler
	SetItemLister(fn func(ctx echo.Context) ([]interface{}, error)) Handler
	OnRender(fn func(ctx echo.Context) error) Handler
	SetIsValid(fn func(ctx echo.Context) bool) Handler
	SetTmpl(tmpl string, typ ...string) Handler
	Tmpl(typ ...string) string
	Generate(ctx echo.Context) (string, error)
	Check(ctx echo.Context, parsed interface{}, current string) (interface{}, error)
	Parse(ctx echo.Context, rule string) (interface{}, error)
	ListItems(ctx echo.Context) ([]interface{}, error)
	FireRender(ctx echo.Context) error
	IsValid(ctx echo.Context) bool
}

type Map

type Map struct {
	V   map[string]*Map `json:",omitempty" xml:",omitempty"`
	Nav *navigate.Item  `json:",omitempty" xml:",omitempty"`
	// contains filtered or unexported fields
}
func NavTreeCached() *Map

func NewMap

func NewMap(cached *Map) *Map

func (*Map) Check

func (m *Map) Check(perm string) bool

Check 检测权限 perm: /a/b/c

func (*Map) CheckCmd

func (m *Map) CheckCmd(perm string) bool

CheckCmd 检测权限

func (*Map) Import

func (m *Map) Import(navList *navigate.List) *Map

Import 导入菜单(用户缓存结果)

func (*Map) Parse

func (m *Map) Parse(permActions string) *Map

Parse 解析用户获取的权限

func (*Map) ParseCmd

func (m *Map) ParseCmd(permCmds string) *Map

ParseCmd 解析用户获取的权限

Jump to

Keyboard shortcuts

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