model

package
v0.0.0-...-ae4999c Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alarm

type Alarm interface {
	DBEntry
	OptionEntry
	Profile

	DeviceID() int64
	MeasureID() int64

	Device() (Device, error)
	Measure() (Measure, error)

	Status() (int, string)
	Confirm(map[string]interface{}) error

	UpdatedAt() time.Time
	Updated()
}

type ApiResource

type ApiResource interface {
	Resource

	GetID() int64
	Title() string
	Desc() string
}

type Comment

type Comment interface {
	DBEntry
	OptionEntry
	Profile

	AlarmID() int64
	Alarm() (Alarm, error)

	UserID() int64
	User() (User, error)

	ParentID() int64
	Parent() (Comment, error)

	SetAlarmID(int64)
	SetUserID(int64)
	SetParentID(int64)

	GetReplyList(options ...helper.OptionFN) ([]Comment, int64, error)
}

type Config

type Config interface {
	DBEntry
	OptionEntry

	Name() string
	UpdateAt() time.Time
}

type DBEntry

type DBEntry interface {
	GetID() int64
	CreatedAt() time.Time

	Save() error
	Destroy() error
}

type Device

type Device interface {
	DBEntry
	EnableEntry
	OptionEntry
	LogEntry
	Profile

	Resource

	Organization() (Organization, error)

	Title() string
	SetTitle(title string)

	SetGroups(groups ...interface{}) error
	Groups() ([]Group, error)

	GetMeasureList(options ...helper.OptionFN) ([]Measure, int64, error)
	CreateMeasure(title string, tag string, kind resource.MeasureKind) (Measure, error)
}

物理设备,网关等

type EnableEntry

type EnableEntry interface {
	Enable()
	Disable()
	IsEnabled() bool
}

type Equipment

type Equipment interface {
	DBEntry
	EnableEntry
	LogEntry
	Profile

	Resource

	Organization() (Organization, error)

	Title() string
	SetTitle(title string)

	Desc() string
	SetDesc(string)

	SetGroups(groups ...interface{}) error
	Groups() ([]Group, error)

	GetStateList(options ...helper.OptionFN) ([]State, int64, error)
	CreateState(title, desc string, measure interface{}, extra map[string]interface{}) (State, error)
}

虚拟设备

type Group

type Group interface {
	DBEntry
	Profile

	Resource

	Organization() (Organization, error)

	Parent() Group
	SetParent(group interface{})

	Title() string
	SetTitle(title string)

	Desc() string
	SetDesc(desc string)

	GetDeviceList(options ...helper.OptionFN) ([]Device, int64, error)
	AddDevice(devices ...interface{}) error
	RemoveDevice(devices ...interface{}) error

	GetEquipmentList(options ...helper.OptionFN) ([]Equipment, int64, error)
	AddEquipment(equipments ...interface{}) error
	RemoveEquipment(equipments ...interface{}) error
}

设备分组

type LogEntry

type LogEntry interface {
	UID() string
	Logger() *logrus.Entry
}

type Map

type Map map[string]interface{}

type Measure

type Measure interface {
	DBEntry
	EnableEntry
	Profile

	Resource

	Device() Device

	Title() string
	SetTitle(title string)

	TagName() string
	Kind() resource.MeasureKind

	Name() string //for cache
}

点位

type OptionEntry

type OptionEntry interface {
	Option() map[string]interface{}
	GetOption(path string) gjson.Result
	SetOption(path string, value interface{}) error
}

type Organization

type Organization interface {
	DBEntry
	EnableEntry
	OptionEntry
	Profile

	Name() string
	Title() string
	SetTitle(string)
}

type Policy

type Policy interface {
	DBEntry
	Profile

	Role() Role

	SetEffect(effect resource.Effect)

	Resource() Resource
	Action() resource.Action
	Effect() resource.Effect
}

策略

type Profile

type Profile interface {
	Simple() Map
	Brief() Map
	Detail() Map
}

type Resource

type Resource interface {
	OrganizationID() int64
	ResourceClass() resource.Class
	ResourceID() int64
	ResourceTitle() string
	ResourceDesc() string
	GetChildrenResources(options ...helper.OptionFN) ([]Resource, int64, error)
}

type Role

type Role interface {
	DBEntry
	EnableEntry
	Profile

	OrganizationID() int64

	Name() string

	Title() string
	SetTitle(title string)

	Desc() string
	SetDesc(desc string)

	//设置指定资源的对于指定action的effect,传入recursiveMap则对子资源进行递归设置,recursiveMap为nil则只设置当前资源
	SetPolicy(res Resource, action resource.Action, effect resource.Effect, recursiveMap map[Resource]struct{}) (Policy, error)

	//对于每个资源,都应该返回一组Policy,表示对该资源的访问权限
	GetPolicy(res Resource) (map[resource.Action]Policy, error)

	RemovePolicy(res Resource) error

	IsAllow(res Resource, action resource.Action) (bool, error)

	GetUserList(options ...helper.OptionFN) ([]User, int64, error)
}

角色

type State

type State interface {
	DBEntry
	EnableEntry
	OptionEntry
	Resource
	Profile

	Measure() Measure
	Equipment() Equipment

	SetMeasure(measure interface{})

	Title() string
	SetTitle(string)

	Desc() string
	SetDesc(string)

	IsAlarmEnabled() bool
	EnableAlarm()
	DisableAlarm()

	AlarmDeadBand() float32
	SetAlarmDeadBand(v float32)

	AlarmDelaySecond() int
	SetAlarmDelay(seconds int)

	GetAlarmEntries() map[string]float32
	GetAlarmEntry(name string) (float32, bool)
	SetAlarmEntry(name string, value float32)
	EnableAlarmEntry(name string)
	DisableAlarmEntry(name string)
}

虚拟设备点位

type User

type User interface {
	DBEntry
	EnableEntry
	LogEntry
	Profile

	OrganizationID() int64
	Organization() (Organization, error)

	Name() string
	Title() string
	Mobile() string
	Email() string

	ResetPassword(password string)
	CheckPassword(password string) bool

	Update(profile Map)

	SetRoles(roles ...interface{}) error
	GetRoles() ([]Role, error)
	Is(role interface{}) (bool, error)

	SetAllow(res Resource, actions ...resource.Action) error
	SetDeny(res Resource, actions ...resource.Action) error

	RemovePolicies(res Resource) error

	IsAllow(res Resource, action resource.Action) (bool, error)
}

用户

Jump to

Keyboard shortcuts

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