Versions in this module Expand all Collapse all v1 v1.9.1 Mar 9, 2022 Changes in this version + const GetCloudDiskCredential + const LogSwitch + func BatchAddChildDevice(childDevices []*Device, tx *gorm.DB) error + func CheckSAExist(device Device, tx *gorm.DB) (err error) + func CopyTable(src *gorm.DB, dst *gorm.DB, table interface{}, delete bool) (err error) + func CreateDepartment(department *Department) error + func CreateDepartmentUser(departmentUsers []DepartmentUser) (err error) + func DelDepartment(id int) (err error) + func DelDepartmentUserByDepID(departmentID int, db *gorm.DB) (err error) + func DelDepartmentUserByUId(userID int, db *gorm.DB) (err error) + func DelDeviceByPID(pid int, tx *gorm.DB) error + func DepartmentNameExist(areaID uint64, name string) bool + func GetDepartmentCount(areaID uint64) (count int64, err error) + func GetDepartmentCountByIds(departmentIds []int) (count int64, err error) + func IsAreaType(areaType AreaType) bool + func IsCompany(areaType AreaType) bool + func IsDepartmentExist(areaID uint64, departmentID int) bool + func IsDepartmentManager(areaID uint64, departmentID, userID int) (isManager bool, err error) + func IsHome(areaType AreaType) bool + func IsMeiHuiZhiJuBrand(pluginID string) bool + func Open(dsn string) gorm.Dialector + func ResetDepartmentManager(areaID uint64, departmentID ...int) (err error) + func UnBindDepartmentDevice(deviceID int) (err error) + func UnBindDepartmentDevices(departmentID int, tx *gorm.DB) (err error) + func UnScopedDelDepartmentUsers(departmentID int) (err error) + func UnScopedDelUserDepartments(userID int) (err error) + func UnbindDepartmentManager(managerID int, areaID uint64, tx *gorm.DB) (err error) + func UpdateDepartment(id int, updateDepartment Department) (err error) + func UpdateDepartmentSort(id int, sort int) (err error) + func UpdateDeviceById(id int, values interface{}, tx *gorm.DB) error + func UpdateSceneByIDWithTx(sceneID int, update *Scene, tx *gorm.DB) (err error) type Area + AreaType AreaType + IsBindCloud bool + IsSendAuthToSC bool + type AreaType int + const AreaOfCompany + const AreaOfHome + func (at AreaType) String() string type Attribute + func (attr *Attribute) Operate(operatorType OperatorType, val interface{}) bool + type Department struct + Area Area + AreaID uint64 + ChildDepartments []Department + CreatedAt time.Time + Deleted gorm.DeletedAt + ID int + ManagerID *int + Name string + ParentDepartmentID *int + Sort int + func GetAllDepartments(parentDepartment []Department) (allDepartment []Department) + func GetDepartmentByID(id int) (department Department, err error) + func GetDepartments(areaID uint64) (departments []Department, err error) + func GetManagerDepartments(areaID uint64, managerID int) (departments []Department, err error) + func GetUserDepartments(userID int) (departments []Department, err error) + func (d *Department) BeforeCreate(tx *gorm.DB) (err error) + func (d Department) BeforeDelete(tx *gorm.DB) (err error) + func (d Department) TableName() string + type DepartmentInfo struct + ID int + IsManager bool + Name string + PId *int + func GetDepartmentsByUser(user User) (departmentInfos []DepartmentInfo, err error) + type DepartmentUser struct + Department Department + DepartmentID int + ID int + User User + UserID int + func WrapDepUsersOfDepID(departmentId int, userIds []int) (departmentUsers []DepartmentUser) + func WrapDepUsersOfUId(userID int, departmentIds []int) (departmentUsers []DepartmentUser) + func (du DepartmentUser) TableName() string type Device + DepartmentID int + PID int + func GetDevicesByDepartmentID(departmentId int) (devices []Device, err error) + func (d Device) Clear() error + func (d Device) IsInit() bool + type Dialector struct + func (dialector Dialector) DataTypeOf(field *schema.Field) string + func (dialector Dialector) Migrator(db *gorm.DB) gorm.Migrator + type GetCloudDiskCredentialSetting struct + GetCloudDiskCredentialSetting bool + func GetDefaultCloudDiskCredentialSetting() GetCloudDiskCredentialSetting type GlobalSetting + func GetAllSetting(areaID uint64) (gsList []GlobalSetting, err error) + type LogSwitchSetting struct + LogSwitch bool + func GetDefaultLogSetting() LogSwitchSetting + type Migrator struct + func (m Migrator) CreateTable(values ...interface{}) error type RoleInfo + func GetRoleInfos(uID int) (roleInfos []RoleInfo, err error) type Scene + Version int + func (s Scene) HaveTimeCondition() bool type TaskLog + DeviceDepartment string type User + PasswordUpdateTime time.Time + func GetDepartmentUsers(departmentID int) (users []User, err error) v1.5.0 Nov 23, 2021 Changes in this version + const StatusInstalling + func AddSADevice(device *Device, tx *gorm.DB) (err error) + func CheckDeviceExist(device Device, tx *gorm.DB) (err error) + func CreateHistory(areaID uint64, deviceID, userID int, context []byte) (err error) + func GetDBWithAreaScopeTx(tx *gorm.DB, areaID uint64) *gorm.DB + func GetDefaultScope() (scope string) + func InitClient() (err error) + func IsOwner(userID int) bool + func IsOwnerOfArea(userID int, areaID uint64) bool + func IsPluginDevelop(pluginID string, areaID uint64) bool + func OpenSqlite(path string, enableForeign bool) (*gorm.DB, error) + func UpdatePluginInfo(pluginID string, pluginInfo PluginInfo) (err error) + func UserRolePermissionsScope(userID int) func(db *gorm.DB) *gorm.DB + type Client struct + AllowScope string + ClientID string + ClientSecret string + GrantType string + ID int + Name string + func CreateClient(grantType, allowScope, name string) (client Client, err error) + func GetClientByClientID(clientID string) (client Client, err error) + func GetSAClient() (client Client, err error) + func GetSCClient() (client Client, err error) + func (c *Client) BeforeCreate(tx *gorm.DB) error + func (c Client) TableName() string type Device + func GetDeviceByIdentity(identity string) (*Device, error) + type DeviceStatusHistory struct + AreaID uint64 + Context datatypes.JSON + CreateAt time.Time + DeviceID int + ID int + UserID int + func GetDeviceHistoryByCondition(deviceID int, areaID uint64) (histories []DeviceStatusHistory, err error) + func (d DeviceStatusHistory) TableName() string type PluginInfo + ConfigMsg datatypes.JSON + ErrorInfo string + Image string + func GetInstalledPlugins() (pis []PluginInfo, err error) type Role + func GetRolesWithTx(tx *gorm.DB, areaID uint64) (roles []Role, err error) type User + Key string + func GetAreaOwner(areaID uint64) (user User, err error) + func GetUserByIDAndAreaID(uID int, areaID uint64) (user User, err error) + func GetUsers(areaID uint64) (users []User, err error) type UserPermissions + func (up UserPermissions) IsDeviceAttrControlPermit(deviceID, instanceID int, attr string) bool + func (up UserPermissions) IsOwner() bool + func (up UserPermissions) IsPermit(tp types.Permission) bool type UserRole + func GetUserRoles(areaID uint64) (userRoles []UserRole, err error) v1.4.0 Oct 19, 2021 Changes in this version + const AreaIDFieldName + const MatchAllCondition + const MatchAnyCondition + const Owner + const OwnerRoleID + const SourceTypeDefault + const SourceTypeDevelopment + const StatusInstallFail + const StatusInstallSuccess + const UserCredentialFoundType + var Tables []interface{} = []interface + func AddDevice(device *Device, tx *gorm.DB) (err error) + func CheckIllegalRepeatDate(repeatDate string) bool + func CheckSceneExitById(sceneId int) (err error) + func CreateLocation(location *Location) error + func CreateScene(scene *Scene) (err error) + func CreateSceneTask(sceneTask []SceneTask) (err error) + func CreateUser(user *User, tx *gorm.DB) (err error) + func CreateUserRole(uRoles []UserRole) (err error) + func DelAreaByID(id uint64) (err error) + func DelDeviceByID(id int) (err error) + func DelDevicesByPlgID(plgID string) (err error) + func DelLocation(id int) (err error) + func DelPlugin(pluginID string, areaID uint64) (err error) + func DelUser(id int) (err error) + func DelUserRoleByUid(userId int, db *gorm.DB) (err error) + func DeleteRole(roleID int) error + func DeleteScene(sceneId int) (err error) + func DeviceControlPermit(userID, deviceID int) bool + func EditLocationSort(id int, sort int) (err error) + func EditUser(id int, updateUser User) (err error) + func FromArea(areaID uint64) func(db *gorm.DB) *gorm.DB + func GetAreaCount() (count int64, err error) + func GetDB() *gorm.DB + func GetDBWithAreaScope(areaID uint64) *gorm.DB + func GetLocationCount(areaID uint64) (count int64, err error) + func GetRoleIdsByUid(userId int) (roleIds []int, err error) + func GetSetting(settingType string, setting interface{}, areaID uint64) (err error) + func GetUIds(areaID uint64) (ids []int, err error) + func InitRole(db *gorm.DB, areaId uint64) (err error) + func IsAccountNameExist(accountName string) bool + func IsAreaOwner(userID int) bool + func IsDeviceActionPermit(roleID int, action string) bool + func IsDeviceControlPermit(userID, deviceID int, attr Attribute) bool + func IsDeviceControlPermitByAttr(userID, deviceID, instanceID int, attr string) bool + func IsDeviceExist(device *Device, tx *gorm.DB) (err error) + func IsLocationExist(areaID uint64, locationID int) bool + func IsPermit(roleID int, action, target, attribute string) bool + func IsPluginAdd(pluginID string, areaID uint64) bool + func IsRoleNameExist(name string, roleID int, areaID uint64) bool + func IsSceneNameExist(name string, sceneId int) (err error) + func JudgePermit(userID int, p types.Permission) bool + func LocationNameExist(areaID uint64, name string) bool + func NewTaskLog(target interface{}, taskID string, parentTaskID *string) error + func PluginDeviceAttr(instanceID int, attr string) string + func SavePluginInfo(pi PluginInfo) (err error) + func SetAreaOwnerID(id uint64, ownerID int, tx *gorm.DB) (err error) + func SwitchAutoScene(scene *Scene, isExecute bool) error + func SwitchAutoSceneByID(sceneID int, isExecute bool) error + func UnBindLocationDevice(deviceID int) (err error) + func UnBindLocationDevices(locationID int) (err error) + func UnScopedDelURoleByUid(userID int) (err error) + func UpdateArea(id uint64, name string) (err error) + func UpdateDevice(id int, updateDevice Device) (err error) + func UpdateLocation(id int, updateLocation Location) (err error) + func UpdateParentLog(parentTaskID string) error + func UpdatePluginStatus(pluginID string, status int) (err error) + func UpdateSetting(settingType string, setting interface{}, areaID uint64) (err error) + func UpdateTaskLog(taskID string, taskErr error) error + type ActionType string + type Area struct + CreatedAt time.Time + Deleted gorm.DeletedAt + ID uint64 + Name string + OwnerID int + func CreateArea(name string) (area Area, err error) + func GetAreaByID(id uint64) (area Area, err error) + func GetAreaResultById(id uint64) (area Area, err error) + func GetAreas() (areas []Area, err error) + func (d *Area) AfterDelete(tx *gorm.DB) (err error) + func (d *Area) BeforeCreate(tx *gorm.DB) (err error) + func (d Area) TableName() string + type Attr struct + Attribute string + DeviceID int + InstanceID int + type AttrMetadata struct + Timestamp int64 + type Attribute struct + InstanceID int + type ConditionInfo struct + Timing int64 + func (c ConditionInfo) CheckCondition(userId int) (err error) + type ConditionType int + const ConditionTypeDeviceStatus + const ConditionTypeTiming + type Device struct + Address string + Area Area + AreaID uint64 + CreatedAt time.Time + Deleted gorm.DeletedAt + ID int + Identity string + LocationID int + Manufacturer string + Model string + Name string + PluginID string + Shadow datatypes.JSON + SwVersion string + ThingModel datatypes.JSON + Type string + func GetDeviceByID(id int) (device Device, err error) + func GetDeviceByIDWithUnscoped(id int) (device Device, err error) + func GetDevices(areaID uint64) (devices []Device, err error) + func GetDevicesByLocationID(locationId int) (devices []Device, err error) + func GetDevicesByPluginID(pluginID string) (devices []Device, err error) + func GetManufacturerDevice(areaID uint64, manufacturer, identity string) (device Device, err error) + func GetPluginDevice(areaID uint64, pluginID, identity string) (device Device, err error) + func GetSaDevice() (device Device, err error) + func GetZhitingDevices() (devices []Device, err error) + func (d *Device) AfterDelete(tx *gorm.DB) (err error) + func (d Device) IsBelongsToUserArea(user User) bool + func (d Device) TableName() string + type GlobalSetting struct + Area Area + AreaID uint64 + Deleted gorm.DeletedAt + ID int + Type string + Value datatypes.JSON + func (g GlobalSetting) TableName() string + type Location struct + Area Area + AreaID uint64 + CreatedAt time.Time + Deleted gorm.DeletedAt + ID int + Name string + Sort int + func GetLocationByID(id int) (location Location, err error) + func GetLocations(areaID uint64) (locations []Location, err error) + func (d *Location) BeforeCreate(tx *gorm.DB) (err error) + func (d Location) IsBelongsToUserArea(user User) bool + func (d Location) TableName() string + type Metadata struct + Desired map[int]map[string]AttrMetadata + Reported map[int]map[string]AttrMetadata + type OperatorType string + const OperatorEQ + const OperatorGT + const OperatorLT + type PluginInfo struct + Area Area + AreaID uint64 + Brand string + ID int + Info datatypes.JSON + PluginID string + Source string + Status int + Version string + func GetDevelopPlugins(areaID uint64) (pis []PluginInfo, err error) + func GetPlugin(pluginID string, areaID uint64) (plugin PluginInfo, err error) + func (p PluginInfo) TableName() string + type RepeatType int + const RepeatTypeAllDay + const RepeatTypeCustom + const RepeatTypeWorkDay + type Role struct + Area Area + AreaID uint64 + Deleted gorm.DeletedAt + ID int + IsManager bool + Name string + func AddManagerRoleWithDB(db *gorm.DB, roleName string, areaID uint64) (Role, error) + func AddRole(roleName string, areaID uint64) (Role, error) + func AddRoleWithDB(db *gorm.DB, roleName string, areaID uint64) (Role, error) + func GetManagerRoleWithDB(db *gorm.DB) (roleInfo Role, err error) + func GetRoleByID(id int) (role Role, err error) + func GetRoles(areaID uint64) (roles []Role, err error) + func GetRolesByIds(roleIds []int) (roles []Role, err error) + func GetRolesByUid(userId int) (roles []Role, err error) + func UpdateRole(roleID int, roleName string) (Role, error) + func (r *Role) AddPermissionForRole(name, action, target, attr string) error + func (r *Role) AddPermissions(ps ...types.Permission) + func (r *Role) AddPermissionsWithDB(db *gorm.DB, ps ...types.Permission) + func (r *Role) AfterDelete(tx *gorm.DB) (err error) + func (r *Role) BeforeCreate(tx *gorm.DB) (err error) + func (r *Role) BeforeDelete(tx *gorm.DB) (err error) + func (r *Role) BeforeUpdate(tx *gorm.DB) (err error) + func (r *Role) DelPermission(p types.Permission) error + func (r Role) IsBelongsToUserArea(user User) bool + func (r Role) TableName() string + type RoleInfo struct + ID int + Name string + type RolePermission struct + Action string + Attribute string + ID int + Name string + Role Role + RoleID int + Target string + func (p RolePermission) TableName() string + type Scene struct + Area Area + AreaID uint64 + AutoRun bool + ConditionLogic int + CreatedAt time.Time + CreatorID int + Deleted gorm.DeletedAt + EffectEnd time.Time + EffectStart time.Time + ID int + IsOn bool + Name string + RepeatDate string + RepeatType RepeatType + SceneConditions []SceneCondition + SceneTasks []SceneTask + TimePeriodType TimePeriodType + func GetPendingScenesByTime(t time.Time) (scenes []Scene, err error) + func GetSceneByIDWithUnscoped(id int) (scene Scene, err error) + func GetSceneById(id int) (scene Scene, err error) + func GetSceneInfoById(id int) (scene Scene, err error) + func GetScenes(areaID uint64) (scenes []Scene, err error) + func GetScenesByCondition(deviceID int, attr Attribute) (scenes []Scene, err error) + func (s *Scene) BeforeSave(tx *gorm.DB) (err error) + func (s Scene) CheckConditionLogic() bool + func (s Scene) CheckPeriodType() (err error) + func (s Scene) CheckRepeatConfig() (err error) + func (s Scene) CheckSceneNameLength() (err error) + func (s Scene) IsMatchAllCondition() bool + func (s Scene) TableName() string + type SceneCondition struct + ConditionAttr datatypes.JSON + ConditionType ConditionType + DeviceID int + ID int + Operator OperatorType + SceneID int + TimingAt time.Time + func GetConditions(deviceID int, attr Attribute) (conds []SceneCondition, err error) + func GetConditionsBySceneID(sceneID int) (conditions []SceneCondition, err error) + func (d SceneCondition) CheckConditionItem(userId, deviceId int) (err error) + func (d SceneCondition) TableName() string + type SceneTask struct + Attributes datatypes.JSON + ControlSceneID int + DelaySeconds int + DeviceID int + ID int + SceneID int + Type TaskType + func GetSceneTasksBySceneID(sceneID int) (sceneTasks []SceneTask, err error) + func (d SceneTask) TableName() string + func (task SceneTask) CheckTaskDevice(userId int) (err error) + func (task SceneTask) CheckTaskType() (err error) + type Shadow struct + Metadata Metadata + State State + Timestamp int + Version int + func NewShadow() Shadow + func (s *Shadow) UpdateReported(instanceID int, attr server.Attribute) + func (s Shadow) Get(instanceID int, attribute string) (val interface{}, err error) + type State struct + Desired map[int]map[string]interface{} + Reported map[int]map[string]interface{} + type TaskLog struct + Area Area + AreaID uint64 + ChildTaskLogs []TaskLog + CreatedAt time.Time + Deleted gorm.DeletedAt + DeviceLocation string + Error string + Finish bool + FinishedAt time.Time + ID int + Name string + ParentTaskID *string + Result TaskResultType + TaskID string + Type TaskType + func (tl TaskLog) TableName() string + type TaskResultType int + const TaskDeviceAlreadyDeleted + const TaskDeviceDisConnect + const TaskFail + const TaskPartSuccess + const TaskSceneAlreadyDeleted + const TaskSuccess + const TaskTimeout + type TaskType int + const TaskTypeDisableAutoRun + const TaskTypeEnableAutoRun + const TaskTypeManualRun + const TaskTypeSmartDevice + type TimePeriodType int + const TimePeriodTypeAllDay + const TimePeriodTypeCustom + type User struct + AccountName string + Area Area + AreaID uint64 + CreatedAt time.Time + Deleted gorm.DeletedAt + ID int + Nickname string + Password string + Phone string + Salt string + Token string + func GetAreaUsers(areaID uint64) (users []User, err error) + func GetUserByAccountName(accountName string) (userInfo User, err error) + func GetUserByID(id int) (user User, err error) + func GetUserByToken(token string) (user User, err error) + func (u *User) BeforeCreate(tx *gorm.DB) (err error) + func (u User) BeforeDelete(tx *gorm.DB) (err error) + func (u User) BelongsToArea(areaID uint64) bool + func (u User) TableName() string + type UserCredentialFoundSetting struct + UserCredentialFound bool + func GetDefaultUserCredentialFoundSetting() UserCredentialFoundSetting + type UserInfo struct + AccountName string + IsSetPassword bool + Nickname string + Phone string + RoleInfos []RoleInfo + Token string + UserId int + type UserPermissions struct + func GetUserPermissions(userID int) (up UserPermissions, err error) + func (up UserPermissions) IsDeviceAttrPermit(deviceID int, attr Attribute) bool + func (up UserPermissions) IsDeviceControlPermit(deviceID, instanceID int, attr string) bool + type UserRole struct + ID int + Role Role + RoleID int + User User + UserID int + func (ur UserRole) TableName() string