mysqlStore

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

Documentation

Index

Constants

View Source
const (
	TbConfig          = "`config`"
	TbOrganization    = "`organizations`"
	TbUsers           = "`users`"
	TbRoles           = "`roles`"
	TbUserRoles       = "`user_roles`"
	TbPolicies        = "`policies`"
	TbGroups          = "`groups`"
	TbDevices         = "`devices`"
	TbMeasures        = "`measures`"
	TbDeviceGroups    = "`device_groups`"
	TbEquipments      = "`equipments`"
	TbStates          = "`states`"
	TbEquipmentGroups = "`equipment_groups`"
	TbApiResources    = "`api_resources`"
	TbAlarms          = "`alarms`"
	TbComments        = "`comments`"
)

Variables

This section is empty.

Functions

func Attach

func Attach(ctx context.Context, db db.DB, cleaners ...func(key string, obj interface{})) store.Store

func CreateData

func CreateData(db db.DB, tbName string, data map[string]interface{}) (int64, error)

func FormatMeasureName

func FormatMeasureName(deviceID int64, tagName string) string

func IsDataExists

func IsDataExists(db db.DB, tbName string, cond string, params ...interface{}) (bool, error)

func LoadData

func LoadData(db db.DB, tbName string, data map[string]interface{}, cond string, params ...interface{}) error

func New

func New() store.Store

func RemoveData

func RemoveData(db db.DB, tbName string, cond string, params ...interface{}) error

func SaveData

func SaveData(db db.DB, tbName string, data map[string]interface{}, cond string, params ...interface{}) error

Types

type Alarm

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

func NewAlarm

func NewAlarm(store *mysqlStore, id int64) *Alarm

func (*Alarm) Brief

func (alarm *Alarm) Brief() model.Map

func (*Alarm) Confirm

func (alarm *Alarm) Confirm(data map[string]interface{}) error

func (*Alarm) CreatedAt

func (alarm *Alarm) CreatedAt() time.Time

func (*Alarm) Destroy

func (alarm *Alarm) Destroy() error

func (*Alarm) Detail

func (alarm *Alarm) Detail() model.Map

func (*Alarm) Device

func (alarm *Alarm) Device() (model.Device, error)

func (*Alarm) DeviceID

func (alarm *Alarm) DeviceID() int64

func (*Alarm) GetID

func (alarm *Alarm) GetID() int64

func (*Alarm) GetOption

func (alarm *Alarm) GetOption(path string) gjson.Result

func (*Alarm) Measure

func (alarm *Alarm) Measure() (model.Measure, error)

func (*Alarm) MeasureID

func (alarm *Alarm) MeasureID() int64

func (*Alarm) Option

func (alarm *Alarm) Option() map[string]interface{}

func (*Alarm) Save

func (alarm *Alarm) Save() error

func (*Alarm) SetOption

func (alarm *Alarm) SetOption(path string, value interface{}) error

func (*Alarm) Simple

func (alarm *Alarm) Simple() model.Map

func (*Alarm) Status

func (alarm *Alarm) Status() (int, string)

func (*Alarm) Updated

func (alarm *Alarm) Updated()

func (*Alarm) UpdatedAt

func (alarm *Alarm) UpdatedAt() time.Time

type ApiResource

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

func NewApiResource

func NewApiResource(store *mysqlStore, id int64) *ApiResource

func (*ApiResource) Desc

func (res *ApiResource) Desc() string

func (*ApiResource) GetChildrenResources

func (res *ApiResource) GetChildrenResources(options ...helper.OptionFN) ([]model.Resource, int64, error)

func (*ApiResource) GetID

func (res *ApiResource) GetID() int64

func (*ApiResource) OrganizationID

func (res *ApiResource) OrganizationID() int64

func (*ApiResource) ResourceClass

func (res *ApiResource) ResourceClass() resource.Class

func (*ApiResource) ResourceDesc

func (res *ApiResource) ResourceDesc() string

func (*ApiResource) ResourceID

func (res *ApiResource) ResourceID() int64

func (*ApiResource) ResourceTitle

func (res *ApiResource) ResourceTitle() string

func (*ApiResource) Title

func (res *ApiResource) Title() string

type Comment

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

func NewComment

func NewComment(s *mysqlStore, id int64) *Comment

func (*Comment) Alarm

func (c *Comment) Alarm() (model.Alarm, error)

func (*Comment) AlarmID

func (c *Comment) AlarmID() int64

func (*Comment) Brief

func (c *Comment) Brief() model.Map

func (*Comment) CreatedAt

func (c *Comment) CreatedAt() time.Time

func (*Comment) Destroy

func (c *Comment) Destroy() error

func (*Comment) Detail

func (c *Comment) Detail() model.Map

func (*Comment) GetID

func (c *Comment) GetID() int64

func (*Comment) GetOption

func (c *Comment) GetOption(path string) gjson.Result

func (*Comment) GetReplyList

func (c *Comment) GetReplyList(options ...helper.OptionFN) ([]model.Comment, int64, error)

func (*Comment) Option

func (c *Comment) Option() map[string]interface{}

func (*Comment) Parent

func (c *Comment) Parent() (model.Comment, error)

func (*Comment) ParentID

func (c *Comment) ParentID() int64

func (*Comment) Save

func (c *Comment) Save() error

func (*Comment) SetAlarmID

func (c *Comment) SetAlarmID(id int64)

func (*Comment) SetOption

func (c *Comment) SetOption(path string, value interface{}) error

func (*Comment) SetParentID

func (c *Comment) SetParentID(id int64)

func (*Comment) SetUserID

func (c *Comment) SetUserID(id int64)

func (*Comment) Simple

func (c *Comment) Simple() model.Map

func (*Comment) User

func (c *Comment) User() (model.User, error)

func (*Comment) UserID

func (c *Comment) UserID() int64

type Config

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

func NewConfig

func NewConfig(store *mysqlStore, id int64) *Config

func (*Config) CreatedAt

func (config *Config) CreatedAt() time.Time

func (*Config) Destroy

func (config *Config) Destroy() error

func (*Config) GetID

func (config *Config) GetID() int64

func (*Config) GetOption

func (config *Config) GetOption(key string) gjson.Result

func (*Config) Name

func (config *Config) Name() string

func (*Config) Option

func (config *Config) Option() map[string]interface{}

func (*Config) Save

func (config *Config) Save() error

func (*Config) SetOption

func (config *Config) SetOption(key string, value interface{}) error

func (*Config) UpdateAt

func (config *Config) UpdateAt() time.Time

type Device

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

func NewDDevice

func NewDDevice(store *mysqlStore, id int64) *Device

func (*Device) Brief

func (d *Device) Brief() model.Map

func (*Device) CreateMeasure

func (d *Device) CreateMeasure(title string, tag string, kind resource.MeasureKind) (model.Measure, error)

func (*Device) CreatedAt

func (d *Device) CreatedAt() time.Time

func (*Device) Destroy

func (d *Device) Destroy() error

func (*Device) Detail

func (d *Device) Detail() model.Map

func (*Device) Disable

func (d *Device) Disable()

func (*Device) Enable

func (d *Device) Enable()

func (*Device) GetChildrenResources

func (d *Device) GetChildrenResources(options ...helper.OptionFN) ([]model.Resource, int64, error)

func (*Device) GetID

func (d *Device) GetID() int64

func (*Device) GetMeasureList

func (d *Device) GetMeasureList(options ...helper.OptionFN) ([]model.Measure, int64, error)

func (*Device) GetOption

func (d *Device) GetOption(key string) gjson.Result

func (*Device) Groups

func (d *Device) Groups() ([]model.Group, error)

func (*Device) IsEnabled

func (d *Device) IsEnabled() bool

func (*Device) Logger

func (d *Device) Logger() *log.Entry

func (*Device) Option

func (d *Device) Option() map[string]interface{}

func (*Device) Organization

func (d *Device) Organization() (model.Organization, error)

func (*Device) OrganizationID

func (d *Device) OrganizationID() int64

func (*Device) ResourceClass

func (d *Device) ResourceClass() resource.Class

func (*Device) ResourceDesc

func (d *Device) ResourceDesc() string

func (*Device) ResourceID

func (d *Device) ResourceID() int64

func (*Device) ResourceTitle

func (d *Device) ResourceTitle() string

func (*Device) Save

func (d *Device) Save() error

func (*Device) SetGroups

func (d *Device) SetGroups(groups ...interface{}) error

func (*Device) SetOption

func (d *Device) SetOption(key string, value interface{}) error

func (*Device) SetTitle

func (d *Device) SetTitle(title string)

func (*Device) Simple

func (d *Device) Simple() model.Map

func (*Device) Title

func (d *Device) Title() string

func (*Device) UID

func (d *Device) UID() string

type Equipment

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

func NewEquipment

func NewEquipment(s *mysqlStore, id int64) *Equipment

func (*Equipment) Brief

func (e *Equipment) Brief() model.Map

func (*Equipment) CreateState

func (e *Equipment) CreateState(title, desc string, measure interface{}, extra map[string]interface{}) (model.State, error)

func (*Equipment) CreatedAt

func (e *Equipment) CreatedAt() time.Time

func (*Equipment) Desc

func (e *Equipment) Desc() string

func (*Equipment) Destroy

func (e *Equipment) Destroy() error

func (*Equipment) Detail

func (e *Equipment) Detail() model.Map

func (*Equipment) Disable

func (e *Equipment) Disable()

func (*Equipment) Enable

func (e *Equipment) Enable()

func (*Equipment) GetChildrenResources

func (e *Equipment) GetChildrenResources(options ...helper.OptionFN) ([]model.Resource, int64, error)

func (*Equipment) GetID

func (e *Equipment) GetID() int64

func (*Equipment) GetStateList

func (e *Equipment) GetStateList(options ...helper.OptionFN) ([]model.State, int64, error)

func (*Equipment) Groups

func (e *Equipment) Groups() ([]model.Group, error)

func (*Equipment) IsEnabled

func (e *Equipment) IsEnabled() bool

func (*Equipment) Logger

func (e *Equipment) Logger() *log.Entry

func (*Equipment) Organization

func (e *Equipment) Organization() (model.Organization, error)

func (*Equipment) OrganizationID

func (e *Equipment) OrganizationID() int64

func (*Equipment) ResourceClass

func (e *Equipment) ResourceClass() resource.Class

func (*Equipment) ResourceDesc

func (e *Equipment) ResourceDesc() string

func (*Equipment) ResourceID

func (e *Equipment) ResourceID() int64

func (*Equipment) ResourceTitle

func (e *Equipment) ResourceTitle() string

func (*Equipment) Save

func (e *Equipment) Save() error

func (*Equipment) SetDesc

func (e *Equipment) SetDesc(desc string)

func (*Equipment) SetGroups

func (e *Equipment) SetGroups(groups ...interface{}) error

func (*Equipment) SetTitle

func (e *Equipment) SetTitle(title string)

func (*Equipment) Simple

func (e *Equipment) Simple() model.Map

func (*Equipment) Title

func (e *Equipment) Title() string

func (*Equipment) UID

func (e *Equipment) UID() string

type Group

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

func NewGroup

func NewGroup(s *mysqlStore, id int64) *Group

func (*Group) AddDevice

func (g *Group) AddDevice(devices ...interface{}) error

func (*Group) AddEquipment

func (g *Group) AddEquipment(equipments ...interface{}) error

func (*Group) Brief

func (g *Group) Brief() model.Map

func (*Group) CreatedAt

func (g *Group) CreatedAt() time.Time

func (*Group) Desc

func (g *Group) Desc() string

func (*Group) Destroy

func (g *Group) Destroy() error

func (*Group) Detail

func (g *Group) Detail() model.Map

func (*Group) GetChildrenResources

func (g *Group) GetChildrenResources(options ...helper.OptionFN) ([]model.Resource, int64, error)

func (*Group) GetDeviceList

func (g *Group) GetDeviceList(options ...helper.OptionFN) ([]model.Device, int64, error)

func (*Group) GetEquipmentList

func (g *Group) GetEquipmentList(options ...helper.OptionFN) ([]model.Equipment, int64, error)

func (*Group) GetID

func (g *Group) GetID() int64

func (*Group) Organization

func (g *Group) Organization() (model.Organization, error)

func (*Group) OrganizationID

func (g *Group) OrganizationID() int64

func (*Group) Parent

func (g *Group) Parent() model.Group

func (*Group) RemoveDevice

func (g *Group) RemoveDevice(devices ...interface{}) error

func (*Group) RemoveEquipment

func (g *Group) RemoveEquipment(equipments ...interface{}) error

func (*Group) ResourceClass

func (g *Group) ResourceClass() resource.Class

func (*Group) ResourceDesc

func (g *Group) ResourceDesc() string

func (*Group) ResourceID

func (g *Group) ResourceID() int64

func (*Group) ResourceTitle

func (g *Group) ResourceTitle() string

func (*Group) Save

func (g *Group) Save() error

func (*Group) SetDesc

func (g *Group) SetDesc(desc string)

func (*Group) SetParent

func (g *Group) SetParent(parent interface{})

func (*Group) SetTitle

func (g *Group) SetTitle(title string)

func (*Group) Simple

func (g *Group) Simple() model.Map

func (*Group) Title

func (g *Group) Title() string

type Measure

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

func NewMeasure

func NewMeasure(s *mysqlStore, id int64) *Measure

func (*Measure) Brief

func (m *Measure) Brief() model.Map

func (*Measure) CreatedAt

func (m *Measure) CreatedAt() time.Time

func (*Measure) Destroy

func (m *Measure) Destroy() error

func (*Measure) Detail

func (m *Measure) Detail() model.Map

func (*Measure) Device

func (m *Measure) Device() model.Device

func (*Measure) Disable

func (m *Measure) Disable()

func (*Measure) Enable

func (m *Measure) Enable()

func (*Measure) GetChildrenResources

func (m *Measure) GetChildrenResources(options ...helper.OptionFN) ([]model.Resource, int64, error)

func (*Measure) GetID

func (m *Measure) GetID() int64

func (*Measure) IsEnabled

func (m *Measure) IsEnabled() bool

func (*Measure) Kind

func (m *Measure) Kind() resource.MeasureKind

func (*Measure) Name

func (m *Measure) Name() string

func (*Measure) OrganizationID

func (m *Measure) OrganizationID() int64

func (*Measure) ResourceClass

func (m *Measure) ResourceClass() resource.Class

func (*Measure) ResourceDesc

func (m *Measure) ResourceDesc() string

func (*Measure) ResourceID

func (m *Measure) ResourceID() int64

func (*Measure) ResourceTitle

func (m *Measure) ResourceTitle() string

func (*Measure) Save

func (m *Measure) Save() error

func (*Measure) SetTitle

func (m *Measure) SetTitle(title string)

func (*Measure) Simple

func (m *Measure) Simple() model.Map

func (*Measure) TagName

func (m *Measure) TagName() string

func (*Measure) Title

func (m *Measure) Title() string

type Organization

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

func NewOrganization

func NewOrganization(store *mysqlStore, id int64) *Organization

func (*Organization) Brief

func (o *Organization) Brief() model.Map

func (*Organization) CreatedAt

func (o *Organization) CreatedAt() time.Time

func (*Organization) Destroy

func (o *Organization) Destroy() error

func (*Organization) Detail

func (o *Organization) Detail() model.Map

func (*Organization) Disable

func (o *Organization) Disable()

func (*Organization) Enable

func (o *Organization) Enable()

func (*Organization) GetID

func (o *Organization) GetID() int64

func (*Organization) GetOption

func (o *Organization) GetOption(path string) gjson.Result

func (*Organization) IsEnabled

func (o *Organization) IsEnabled() bool

func (*Organization) Name

func (o *Organization) Name() string

func (*Organization) Option

func (o *Organization) Option() map[string]interface{}

func (*Organization) Save

func (o *Organization) Save() error

func (*Organization) SetOption

func (o *Organization) SetOption(path string, value interface{}) error

func (*Organization) SetTitle

func (o *Organization) SetTitle(title string)

func (*Organization) Simple

func (o *Organization) Simple() model.Map

func (*Organization) Title

func (o *Organization) Title() string

type Policy

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

func NewPolicy

func NewPolicy(s *mysqlStore, id int64) *Policy

func (*Policy) Action

func (p *Policy) Action() resource.Action

func (*Policy) Brief

func (p *Policy) Brief() model.Map

func (*Policy) CreatedAt

func (p *Policy) CreatedAt() time.Time

func (*Policy) Destroy

func (p *Policy) Destroy() error

func (*Policy) Detail

func (p *Policy) Detail() model.Map

func (*Policy) Effect

func (p *Policy) Effect() resource.Effect

func (*Policy) GetID

func (p *Policy) GetID() int64

func (*Policy) Resource

func (p *Policy) Resource() model.Resource

func (*Policy) Role

func (p *Policy) Role() model.Role

func (*Policy) Save

func (p *Policy) Save() error

func (*Policy) SetEffect

func (p *Policy) SetEffect(effect resource.Effect)

func (*Policy) Simple

func (p *Policy) Simple() model.Map

type Role

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

func NewRole

func NewRole(s *mysqlStore, id int64) *Role

func (*Role) Brief

func (r *Role) Brief() model.Map

func (*Role) CreatedAt

func (r *Role) CreatedAt() time.Time

func (*Role) Desc

func (r *Role) Desc() string

func (*Role) Destroy

func (r *Role) Destroy() error

func (*Role) Detail

func (r *Role) Detail() model.Map

func (*Role) Disable

func (r *Role) Disable()

func (*Role) Enable

func (r *Role) Enable()

func (*Role) GetID

func (r *Role) GetID() int64

func (*Role) GetPolicy

func (r *Role) GetPolicy(res model.Resource) (map[resource.Action]model.Policy, error)

func (*Role) GetUserList

func (r *Role) GetUserList(options ...helper.OptionFN) ([]model.User, int64, error)

func (*Role) IsAllow

func (r *Role) IsAllow(res model.Resource, action resource.Action) (bool, error)

func (*Role) IsEnabled

func (r *Role) IsEnabled() bool

func (*Role) Name

func (r *Role) Name() string

func (*Role) Organization

func (r *Role) Organization() (model.Organization, error)

func (*Role) OrganizationID

func (r *Role) OrganizationID() int64

func (*Role) RemovePolicy

func (r *Role) RemovePolicy(res model.Resource) error

func (*Role) Save

func (r *Role) Save() error

func (*Role) SetDesc

func (r *Role) SetDesc(desc string)

func (*Role) SetPolicy

func (r *Role) SetPolicy(res model.Resource, action resource.Action, effect resource.Effect, recursiveMap map[model.Resource]struct{}) (model.Policy, error)

func (*Role) SetTitle

func (r *Role) SetTitle(title string)

func (*Role) Simple

func (r *Role) Simple() model.Map

func (*Role) Title

func (r *Role) Title() string

type State

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

func NewState

func NewState(s *mysqlStore, id int64) *State

func (*State) AlarmDeadBand

func (s *State) AlarmDeadBand() float32

func (*State) AlarmDelaySecond

func (s *State) AlarmDelaySecond() int

func (*State) Brief

func (s *State) Brief() model.Map

func (*State) CreatedAt

func (s *State) CreatedAt() time.Time

func (*State) Desc

func (s *State) Desc() string

func (*State) Destroy

func (s *State) Destroy() error

func (*State) Detail

func (s *State) Detail() model.Map

func (*State) Disable

func (s *State) Disable()

func (*State) DisableAlarm

func (s *State) DisableAlarm()

func (*State) DisableAlarmEntry

func (s *State) DisableAlarmEntry(name string)

func (*State) Enable

func (s *State) Enable()

func (*State) EnableAlarm

func (s *State) EnableAlarm()

func (*State) EnableAlarmEntry

func (s *State) EnableAlarmEntry(name string)

func (*State) Equipment

func (s *State) Equipment() model.Equipment

func (*State) GetAlarmEntries

func (s *State) GetAlarmEntries() map[string]float32

func (*State) GetAlarmEntry

func (s *State) GetAlarmEntry(name string) (float32, bool)

func (*State) GetChildrenResources

func (s *State) GetChildrenResources(options ...helper.OptionFN) ([]model.Resource, int64, error)

func (*State) GetID

func (s *State) GetID() int64

func (*State) GetOption

func (s *State) GetOption(path string) gjson.Result

func (*State) IsAlarmEnabled

func (s *State) IsAlarmEnabled() bool

func (*State) IsEnabled

func (s *State) IsEnabled() bool

func (*State) Measure

func (s *State) Measure() model.Measure

func (*State) Option

func (s *State) Option() map[string]interface{}

func (*State) OrganizationID

func (s *State) OrganizationID() int64

func (*State) ResourceClass

func (s *State) ResourceClass() resource.Class

func (*State) ResourceDesc

func (s *State) ResourceDesc() string

func (*State) ResourceID

func (s *State) ResourceID() int64

func (*State) ResourceTitle

func (s *State) ResourceTitle() string

func (*State) Save

func (s *State) Save() error

func (*State) SetAlarmDeadBand

func (s *State) SetAlarmDeadBand(v float32)

func (*State) SetAlarmDelay

func (s *State) SetAlarmDelay(seconds int)

func (*State) SetAlarmEntry

func (s *State) SetAlarmEntry(name string, value float32)

func (*State) SetDesc

func (s *State) SetDesc(desc string)

func (*State) SetMeasure

func (s *State) SetMeasure(measure interface{})

func (*State) SetOption

func (s *State) SetOption(path string, value interface{}) error

func (*State) SetTitle

func (s *State) SetTitle(title string)

func (*State) Simple

func (s *State) Simple() model.Map

func (*State) Title

func (s *State) Title() string

type User

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

func NewUser

func NewUser(s *mysqlStore, id int64) *User

func (*User) Brief

func (u *User) Brief() model.Map

func (*User) CheckPassword

func (u *User) CheckPassword(password string) bool

func (*User) CreatedAt

func (u *User) CreatedAt() time.Time

func (*User) Destroy

func (u *User) Destroy() error

func (*User) Detail

func (u *User) Detail() model.Map

func (*User) Disable

func (u *User) Disable()

func (*User) Email

func (u *User) Email() string

func (*User) Enable

func (u *User) Enable()

func (*User) GetID

func (u *User) GetID() int64

func (*User) GetRoles

func (u *User) GetRoles() ([]model.Role, error)

func (*User) Is

func (u *User) Is(role interface{}) (bool, error)

func (*User) IsAllow

func (u *User) IsAllow(res model.Resource, action resource.Action) (bool, error)

func (*User) IsEnabled

func (u *User) IsEnabled() bool

func (*User) Logger

func (u *User) Logger() *log.Entry

func (*User) Mobile

func (u *User) Mobile() string

func (*User) Name

func (u *User) Name() string

func (*User) Organization

func (u *User) Organization() (model.Organization, error)

func (*User) OrganizationID

func (u *User) OrganizationID() int64

func (*User) RemovePolicies

func (u *User) RemovePolicies(res model.Resource) error

func (*User) ResetPassword

func (u *User) ResetPassword(password string)

func (*User) Save

func (u *User) Save() error

func (*User) SetAllow

func (u *User) SetAllow(res model.Resource, actions ...resource.Action) error

func (*User) SetDeny

func (u *User) SetDeny(res model.Resource, actions ...resource.Action) error

func (*User) SetRoles

func (u *User) SetRoles(roles ...interface{}) error

func (*User) Simple

func (u *User) Simple() model.Map

func (*User) Title

func (u *User) Title() string

func (*User) UID

func (u *User) UID() string

func (*User) Update

func (u *User) Update(profile model.Map)

Jump to

Keyboard shortcuts

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