Documentation ¶
Index ¶
- Variables
- func HashPass(pass string) string
- func Init()
- type GroupImpl
- func (u *GroupImpl) Count(cond *db.Condition) (int64, error)
- func (u *GroupImpl) Delete(id uuid.UUID) (ok bool, err error)
- func (u *GroupImpl) DeleteAll() (cnt int64, err error)
- func (u *GroupImpl) Get(id uuid.UUID) (*db.UserGroup, error)
- func (u *GroupImpl) GetAll(cond *db.Condition) ([]*db.UserGroup, error)
- func (u *GroupImpl) GetByName(name string) (*db.UserGroup, error)
- func (u *GroupImpl) GetGroupAllUser(id uuid.UUID) ([]*db.User, error)
- func (u *GroupImpl) GetUserAllGroup(id uuid.UUID) ([]*db.UserGroup, error)
- func (u *GroupImpl) Link(uid []uuid.UUID, gid []uuid.UUID) ([]*db.UserGroupLink, error)
- func (u *GroupImpl) New(name string, note string) (*db.UserGroup, error)
- func (u *GroupImpl) Unlink(uid uuid.UUID, gid uuid.UUID) (int64, error)
- func (u *GroupImpl) Update(id uuid.UUID, name string, note *string) error
- func (u *GroupImpl) WithTx(tx *gorm.DB) *GroupImpl
- type NotificationHook
- type NotificationImpl
- func (u *NotificationImpl) Count(cond *db.Condition) (int64, error)
- func (u *NotificationImpl) Delete(id uuid.UUID) (bool, error)
- func (u *NotificationImpl) DeleteAll() (int64, error)
- func (u *NotificationImpl) Get(id uuid.UUID) (*db.Notification, error)
- func (u *NotificationImpl) GetAll(cond *db.Condition) ([]*db.Notification, error)
- func (s *NotificationImpl) New(level db.NotifyLevel, name string, message string, detail string) error
- func (p *NotificationImpl) WithTx(tx *gorm.DB) *NotificationImpl
- type Perm
- type PermList
- type PermListType
- type PermissionImpl
- func (p *PermissionImpl) AddToGroup(gid uuid.UUID, perm []*Perm) (permRet []*db.Permission, err error)
- func (p *PermissionImpl) DeleteAll(uid uuid.UUID, gid uuid.UUID) (row int64, err error)
- func (p *PermissionImpl) GetAll(uid uuid.UUID, gid uuid.UUID, join bool) ([]*db.Permission, error)
- func (p *PermissionImpl) GetGroup(id uuid.UUID, force bool) (*PermList, error)
- func (p *PermissionImpl) GetUser(id uuid.UUID, force bool) (ret *PermList, err error)
- func (p *PermissionImpl) GetUserMerged(id uuid.UUID) (map[uuid.UUID]*Perm, error)
- func (p *PermissionImpl) WithTx(tx *gorm.DB) *PermissionImpl
- type PluginEntry
- type PluginImpl
- func (p *PluginImpl) CleanSetting()
- func (p *PluginImpl) Count() int
- func (p *PluginImpl) Disable(id uuid.UUID) error
- func (p *PluginImpl) Enable(id uuid.UUID) error
- func (p *PluginImpl) Fini()
- func (p *PluginImpl) Get(id uuid.UUID) *PluginEntry
- func (p *PluginImpl) GetAll() []*PluginEntry
- func (p *PluginImpl) LoadPlugin(base string) error
- type PluginSkynetAPI
- type SettingImpl
- func (s *SettingImpl) BuildCache() error
- func (s *SettingImpl) Delete(name string) (bool, error)
- func (s *SettingImpl) DeleteAll() (int64, error)
- func (s *SettingImpl) Get(name string) (string, bool)
- func (s *SettingImpl) GetAll() map[string]string
- func (s *SettingImpl) Set(name string, value string) error
- func (p *SettingImpl) WithTx(tx *gorm.DB) *SettingImpl
- type UserImpl
- func (u *UserImpl) CheckPass(user string, pass string) (*db.User, int, error)
- func (u *UserImpl) Count(cond *db.Condition) (int64, error)
- func (u *UserImpl) Delete(id uuid.UUID) (ok bool, err error)
- func (u *UserImpl) DeleteAll() (int64, error)
- func (u *UserImpl) Get(id uuid.UUID) (*db.User, error)
- func (u *UserImpl) GetAll(cond *db.Condition) ([]*db.User, error)
- func (u *UserImpl) GetByName(name string) (*db.User, error)
- func (u *UserImpl) Kick(id uuid.UUID) error
- func (u *UserImpl) New(username string, password string, avatar []byte) (user *db.User, newpass string, err error)
- func (u *UserImpl) Reset(id uuid.UUID) (string, error)
- func (u *UserImpl) Update(id uuid.UUID, username string, password string, avatar []byte, ...) error
- func (u *UserImpl) WithTx(tx *gorm.DB) *UserImpl
Constants ¶
This section is empty.
Variables ¶
var ( ErrPluginNotFound = tracerr.New("plugin not found") ErrPluginIDDuplicate = tracerr.New("plugin ID duplicated") ErrPluginInvalid = tracerr.New("plugin invalid") ErrPluginExists = tracerr.New("plugin already exists") ErrPluginIDNotMatch = tracerr.New("plugin id not match") ErrPluginMethod = tracerr.New("plugin method error") )
var ErrUUIDConflict = tracerr.New("uuid conflict")
var Group = &GroupImpl{}
var Notification = &NotificationImpl{}
var Permission = &PermissionImpl{ cache: new(tpl.SafeMap[uuid.UUID, *PermList]), }
var Plugin = &PluginImpl{}
var Setting = &SettingImpl{ cache: new(tpl.SafeMap[string, string]), }
var User = &UserImpl{}
Functions ¶
Types ¶
type GroupImpl ¶
type GroupImpl struct {
// contains filtered or unexported fields
}
func (*GroupImpl) Delete ¶
Delete delete user group data.
Warning: this function will not delete permission.
func (*GroupImpl) DeleteAll ¶
DeleteAll delete all user group data.
Warning: this function will not delete permission.
func (*GroupImpl) GetGroupAllUser ¶
GetGroupAllUser get group id all users.
func (*GroupImpl) GetUserAllGroup ¶
GetUserAllGroup get user id all groups.
func (*GroupImpl) Link ¶
Link link all uid user to all gid group.
Note: For performance reasons, this function will not check whether uid or gid is valid.
func (*GroupImpl) Unlink ¶
Unlink delete user data in user group. When gid is uuid.Nil, delete user in all group. When uid is uuid.Nil, delete group all user.
Warning: this function will not delete permission.
type NotificationHook ¶
type NotificationHook struct{}
func (NotificationHook) Levels ¶
func (h NotificationHook) Levels() []logrus.Level
type NotificationImpl ¶
type NotificationImpl struct {
// contains filtered or unexported fields
}
func (*NotificationImpl) Count ¶
func (u *NotificationImpl) Count(cond *db.Condition) (int64, error)
Count count notification by condition.
func (*NotificationImpl) Delete ¶
func (u *NotificationImpl) Delete(id uuid.UUID) (bool, error)
Delete delete notification by id.
func (*NotificationImpl) DeleteAll ¶
func (u *NotificationImpl) DeleteAll() (int64, error)
Delete delete all notification.
func (*NotificationImpl) Get ¶
func (u *NotificationImpl) Get(id uuid.UUID) (*db.Notification, error)
Get get notification by id.
func (*NotificationImpl) GetAll ¶
func (u *NotificationImpl) GetAll(cond *db.Condition) ([]*db.Notification, error)
GetAll get all notification by condition.
func (*NotificationImpl) New ¶
func (s *NotificationImpl) New(level db.NotifyLevel, name string, message string, detail string) error
func (*NotificationImpl) WithTx ¶
func (p *NotificationImpl) WithTx(tx *gorm.DB) *NotificationImpl
type PermListType ¶
type PermListType int32
const ( PermListUser PermListType = iota PermListGroup )
type PermissionImpl ¶
type PermissionImpl struct {
// contains filtered or unexported fields
}
func (*PermissionImpl) AddToGroup ¶
func (p *PermissionImpl) AddToGroup(gid uuid.UUID, perm []*Perm) (permRet []*db.Permission, err error)
AddToGroup add permission to group gid.
func (*PermissionImpl) DeleteAll ¶
DeleteAll delete all uid or gid permission.
Note: uid or gid is uuid.Nil means not base on this condition. If both uuid.Nil, do nothing. If both given, delete using OR condition.
func (*PermissionImpl) GetAll ¶
func (p *PermissionImpl) GetAll(uid uuid.UUID, gid uuid.UUID, join bool) ([]*db.Permission, error)
GetAll find all permission by condition, if join is true, return records will join PermissionList.
uid and gid should not be both uuid.Nil or both have value, otherwise, nil,nil will be returned
func (*PermissionImpl) GetUserMerged ¶
GetUserMerged returns merged user permission list.
func (*PermissionImpl) WithTx ¶
func (p *PermissionImpl) WithTx(tx *gorm.DB) *PermissionImpl
type PluginEntry ¶
type PluginEntry struct { ID uuid.UUID `json:"id" yaml:"id"` // plugin unique ID Name string `json:"name" yaml:"name"` // plugin name, unique suggested Version string `json:"version" yaml:"version"` // plugin version SkynetVersion string `json:"skynet_version" yaml:"skynet_version"` // compatible skynet version CommandUnix string `json:"-" yaml:"command_unix"` // unix execute command CommandWindows string `json:"-" yaml:"command_windows"` // windows execute command Path string `json:"path" yaml:"-"` // runtime relative path Enable bool `json:"enable" yaml:"-"` // is plugin enabled Message string `json:"message" yaml:"-"` // plugin message Client *plugin.Client `json:"-" yaml:"-"` // go-plugin client API *PluginSkynetAPI `json:"-" yaml:"-"` // plugin API }
func (*PluginEntry) KillPlugin ¶
func (p *PluginEntry) KillPlugin()
func (*PluginEntry) StartPlugin ¶
func (p *PluginEntry) StartPlugin() error
type PluginImpl ¶
type PluginImpl struct { BaseFolder string // contains filtered or unexported fields }
func (*PluginImpl) CleanSetting ¶
func (p *PluginImpl) CleanSetting()
func (*PluginImpl) Count ¶
func (p *PluginImpl) Count() int
func (*PluginImpl) Fini ¶
func (p *PluginImpl) Fini()
func (*PluginImpl) Get ¶
func (p *PluginImpl) Get(id uuid.UUID) *PluginEntry
func (*PluginImpl) GetAll ¶
func (p *PluginImpl) GetAll() []*PluginEntry
func (*PluginImpl) LoadPlugin ¶
func (p *PluginImpl) LoadPlugin(base string) error
type PluginSkynetAPI ¶
func (*PluginSkynetAPI) Disable ¶
func (p *PluginSkynetAPI) Disable() (*sp.PluginError, error)
func (*PluginSkynetAPI) Enable ¶
func (p *PluginSkynetAPI) Enable() (*sp.PluginError, error)
type SettingImpl ¶
type SettingImpl struct {
// contains filtered or unexported fields
}
func (*SettingImpl) BuildCache ¶
func (s *SettingImpl) BuildCache() error
func (*SettingImpl) Delete ¶
func (s *SettingImpl) Delete(name string) (bool, error)
Delete delete name setting.
func (*SettingImpl) DeleteAll ¶
func (s *SettingImpl) DeleteAll() (int64, error)
DeleteAll delete all settings.
func (*SettingImpl) Get ¶
func (s *SettingImpl) Get(name string) (string, bool)
Get get name setting.
func (*SettingImpl) GetAll ¶
func (s *SettingImpl) GetAll() map[string]string
GetAll return all settings.
Copies are returned, modification will not be saved.
func (*SettingImpl) Set ¶
func (s *SettingImpl) Set(name string, value string) error
Set set setting name with value.
func (*SettingImpl) WithTx ¶
func (p *SettingImpl) WithTx(tx *gorm.DB) *SettingImpl
type UserImpl ¶
type UserImpl struct {
// contains filtered or unexported fields
}
func (*UserImpl) CheckPass ¶
CheckPass check whether user and pass match.
If error, return nil,-1,err.
If user not found, return nil,1,nil.
If pass not match, return nil,2,nil.
Return user,0,nil if all match.
func (*UserImpl) Delete ¶
Delete delete user data.
Warning: this function will not delete permission or unlink group.
func (*UserImpl) DeleteAll ¶
Delete delete all user data.
Warning: this function will not delete permission or unlink group.
func (*UserImpl) New ¶
func (u *UserImpl) New(username string, password string, avatar []byte) (user *db.User, newpass string, err error)
New create new user and return created user and created pass, when password is empty, generate random pass, by default no user group will be attached.
func (*UserImpl) Reset ¶
Reset reset user password by id, return new password.
Return "",nil when user not found.