actual

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: AGPL-3.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Path_Seperator = "."
	Path_RootChar  = "/"
	Path_FuzzyChar = "*"
	Path_StartChar = "["
	Path_EndChar   = "]"
)
View Source
const (
	StartPosition_Root    = "R"
	StartPosition_Current = "C"
	StartPosition_Fuzzy   = "F"
)

*

  • @Description: R:从根节点开始;C:从当前节点开始;F:模糊查询
  • @author: Jason
  • @date: 2017年4月17日 下午8:24:56 *

Variables

View Source
var MemCache = cache.NewMemCache("actual", 60, 10)

Functions

func Delete

func Delete(schemaName string, ids []uint64) (int64, error)

* 角色没有加载,直接删除数据库

func GetLastKind

func GetLastKind(path string) string

*

  • @Description: 获取最后的名称
  • @param path
  • @return

func GetRolePath

func GetRolePath(path string) string

*

  • @Description: 获取路径
  • @param path
  • @return

func Save

func Save(schemaName string, id uint64) (int, error)

Types

type Node

type Node struct {
	Kind     string
	Position int
}

type PositionPath

type PositionPath struct {
	Current  int
	Starter  string //StartPosition.R
	Nodes    []*Node
	SpecType string
}

func NewPositionPath

func NewPositionPath(path string) *PositionPath

type Role

type Role struct {
	entity.Role `json:",omitempty"`
	RoleSpec    *spec.RoleSpec `json:"-,omitempty"`
	// 以固定属性存在的直接下属属性,在非关系数据库(bolt)的时候所有的字段可以动态地全部存放,Properties将为空
	FixedActual interface{} `json:",omitempty"`
	// 所有下属属性的前端交互的脏标志
	PropertyStates map[string]string `json:"-,omitempty"`
	// 所有的直接下属角色实例,kind为键值的数组
	Roles       map[string][]*Role            `json:",omitempty"`
	Connections map[uint64]*entity.Connection `json:",omitempty"`
	// 所有的直接下属属性元素实例
	Properties []*entity.Property `json:",omitempty"`
	// 所有的直接下属行为结果实例
	ActionResults map[string]*entity.ActionResult `json:",omitempty"`
	/**
	删除的role,保存数据库结束后清除
	*/
	DeleteRoles map[uint64]*Role `json:",omitempty"`
	/**
	删除的角色的编号,用于通知前端,返回前端后清除
	*/
	DeleteActuals []uint64 `json:",omitempty"`
	ParentRole    *Role    `json:"-,omitempty"`
	// contains filtered or unexported fields
}

func Create

func Create(schemaName string, roleSpec *spec.RoleSpec) *Role

func Get

func Get(schemaName string, id uint64) *Role

func Load

func Load(schemaName string, id uint64) *Role

* 从数据库装载实例树

func (*Role) AddRole

func (this *Role) AddRole(subRoleSpec *spec.RoleSpec, values map[string]interface{}) *Role

func (*Role) AddRoles

func (this *Role) AddRoles(subRoleSpec *spec.RoleSpec, count int, values []map[string]interface{}) *[]*Role

func (*Role) CanbeAdd

func (this *Role) CanbeAdd(specId uint64) int

func (*Role) CanbeRemove

func (this *Role) CanbeRemove(specId uint64) int

func (*Role) Delete

func (this *Role) Delete() int64

* 角色已经加载,删除角色

func (*Role) Find

func (this *Role) Find(path string) (interface{}, string, bool)

func (*Role) Get

func (this *Role) Get(id uint64) *Role

func (*Role) GetActual

func (this *Role) GetActual(isState bool) map[string]interface{}

func (*Role) GetCount

func (this *Role) GetCount(kind string) int

func (*Role) GetMultiplicity

func (this *Role) GetMultiplicity(specId uint64) (int, int)

func (*Role) GetPropertyValue

func (this *Role) GetPropertyValue(kind string) (interface{}, error)

func (*Role) GetValue

func (this *Role) GetValue(path string) (interface{}, error)

func (*Role) Load

func (this *Role) Load(kind string) []*Role

* 加载子角色,用于懒加载,loadNum为-1的情况

func (*Role) PutActionResult

func (this *Role) PutActionResult(actionResult *entity.ActionResult) error

func (*Role) PutConnection

func (this *Role) PutConnection(conn *entity.Connection) error

func (*Role) PutFixedActual

func (this *Role) PutFixedActual(fixedActual interface{}) error

func (*Role) PutProperty

func (this *Role) PutProperty(property *entity.Property) (err error)

* 把属性放入角色中,属性可能只有值,无specId,计算属性也未填充

func (*Role) PutRole

func (this *Role) PutRole(role *Role) error

func (*Role) RemoveRole

func (this *Role) RemoveRole(role *Role) bool

func (*Role) SaveAll

func (this *Role) SaveAll() (int, error)

* 开启事务,保存树

func (*Role) SetActual

func (this *Role) SetActual(actual map[string]interface{}, isState bool, isCheckActualId bool) map[uint64]map[string]error

func (*Role) SetPropertyValue

func (this *Role) SetPropertyValue(kind string, value interface{}) (bool, error)

*

  • @param kind
  • @param value
  • @return
  • @Description: 根据属性kind和位置设置属性值 先设置角色对象的值, 再设置静态属性的值,不成功设置到动态属性的值,
  • 设置成功,更新角色脏标志

func (*Role) SetValue

func (this *Role) SetValue(path string, value interface{}) (bool, error)

func (*Role) UpdateProperty

func (this *Role) UpdateProperty() error

*

  • 检查属性和定义是否匹配,如果定义有增加,则增加新的属性
  • @return

func (*Role) Version

func (role *Role) Version() *Role

* 克隆角色树,所有的数据保留,编号更新

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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