relationDB

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(c conf.Database) error

Types

type AlarmInfoFilter

type AlarmInfoFilter struct {
	Name string
}

type AlarmInfoRepo

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

func NewAlarmInfoRepo

func NewAlarmInfoRepo(in any) *AlarmInfoRepo

func (AlarmInfoRepo) CountByFilter

func (p AlarmInfoRepo) CountByFilter(ctx context.Context, f AlarmInfoFilter) (size int64, err error)

func (AlarmInfoRepo) Delete

func (p AlarmInfoRepo) Delete(ctx context.Context, id int64) error

func (AlarmInfoRepo) DeleteByFilter

func (p AlarmInfoRepo) DeleteByFilter(ctx context.Context, f AlarmInfoFilter) error

func (AlarmInfoRepo) FindByFilter

func (p AlarmInfoRepo) FindByFilter(ctx context.Context, f AlarmInfoFilter, page *stores.PageInfo) ([]*UdAlarmInfo, error)

func (AlarmInfoRepo) FindOne

func (p AlarmInfoRepo) FindOne(ctx context.Context, id int64) (*UdAlarmInfo, error)

func (AlarmInfoRepo) FindOneByFilter

func (p AlarmInfoRepo) FindOneByFilter(ctx context.Context, f AlarmInfoFilter) (*UdAlarmInfo, error)

func (AlarmInfoRepo) Insert

func (p AlarmInfoRepo) Insert(ctx context.Context, data *UdAlarmInfo) error

func (AlarmInfoRepo) MultiInsert

func (p AlarmInfoRepo) MultiInsert(ctx context.Context, data []*UdAlarmInfo) error

批量插入 LightStrategyDevice 记录

func (AlarmInfoRepo) Update

func (p AlarmInfoRepo) Update(ctx context.Context, data *UdAlarmInfo) error

type AlarmRecordFilter

type AlarmRecordFilter struct {
	AlarmID       int64 // 告警配置ID
	AlarmName     string
	TriggerType   scene.TriggerType
	WorkOrderID   int64 //工作流ID
	DeviceAlias   string
	ProductID     string
	DeviceName    string
	DealStatus    scene.AlarmDealStatus
	DealStatuses  []scene.AlarmDealStatus
	Time          *def.TimeRange
	WithSceneInfo bool
}

type AlarmRecordRepo

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

func NewAlarmRecordRepo

func NewAlarmRecordRepo(in any) *AlarmRecordRepo

func (AlarmRecordRepo) CountByFilter

func (p AlarmRecordRepo) CountByFilter(ctx context.Context, f AlarmRecordFilter) (size int64, err error)

func (AlarmRecordRepo) Delete

func (p AlarmRecordRepo) Delete(ctx context.Context, id int64) error

func (AlarmRecordRepo) DeleteByFilter

func (p AlarmRecordRepo) DeleteByFilter(ctx context.Context, f AlarmRecordFilter) error

func (AlarmRecordRepo) FindByFilter

func (p AlarmRecordRepo) FindByFilter(ctx context.Context, f AlarmRecordFilter, page *stores.PageInfo) ([]*UdAlarmRecord, error)

func (AlarmRecordRepo) FindOne

func (p AlarmRecordRepo) FindOne(ctx context.Context, id int64) (*UdAlarmRecord, error)

func (AlarmRecordRepo) FindOneByFilter

func (p AlarmRecordRepo) FindOneByFilter(ctx context.Context, f AlarmRecordFilter) (*UdAlarmRecord, error)

func (AlarmRecordRepo) Insert

func (p AlarmRecordRepo) Insert(ctx context.Context, data *UdAlarmRecord) error

func (AlarmRecordRepo) MultiInsert

func (p AlarmRecordRepo) MultiInsert(ctx context.Context, data []*UdAlarmRecord) error

批量插入 LightStrategyDevice 记录

func (AlarmRecordRepo) Update

func (p AlarmRecordRepo) Update(ctx context.Context, data *UdAlarmRecord) error

func (AlarmRecordRepo) UpdateWithField

func (d AlarmRecordRepo) UpdateWithField(ctx context.Context, f AlarmRecordFilter, updates map[string]any) error

type AlarmSceneFilter

type AlarmSceneFilter struct {
	AlarmID       int64 // 告警配置ID
	SceneID       int64 // 场景ID
	WithAlarmInfo bool
	WithSceneInfo bool
}

type AlarmSceneRepo

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

func NewAlarmSceneRepo

func NewAlarmSceneRepo(in any) *AlarmSceneRepo

func (AlarmSceneRepo) CountByFilter

func (p AlarmSceneRepo) CountByFilter(ctx context.Context, f AlarmSceneFilter) (size int64, err error)

func (AlarmSceneRepo) Delete

func (p AlarmSceneRepo) Delete(ctx context.Context, id int64) error

func (AlarmSceneRepo) DeleteByFilter

func (p AlarmSceneRepo) DeleteByFilter(ctx context.Context, f AlarmSceneFilter) error

func (AlarmSceneRepo) FindByFilter

func (p AlarmSceneRepo) FindByFilter(ctx context.Context, f AlarmSceneFilter, page *stores.PageInfo) ([]*UdAlarmScene, error)

func (AlarmSceneRepo) FindOne

func (p AlarmSceneRepo) FindOne(ctx context.Context, id int64) (*UdAlarmScene, error)

func (AlarmSceneRepo) FindOneByFilter

func (p AlarmSceneRepo) FindOneByFilter(ctx context.Context, f AlarmSceneFilter) (*UdAlarmScene, error)

func (AlarmSceneRepo) Insert

func (p AlarmSceneRepo) Insert(ctx context.Context, data *UdAlarmScene) error

func (AlarmSceneRepo) MultiInsert

func (p AlarmSceneRepo) MultiInsert(ctx context.Context, data []*UdAlarmScene) error

批量插入 LightStrategyDevice 记录

func (AlarmSceneRepo) Update

func (p AlarmSceneRepo) Update(ctx context.Context, data *UdAlarmScene) error

type DeviceTimerInfoFilter

type DeviceTimerInfoFilter struct {
	Devices     []*devices.Core
	TriggerType string
	Status      int64
	ExecAt      *stores.Cmp
	LastRunTime *stores.Cmp
	Repeat      *stores.Cmp
}

type DeviceTimingInfoRepo

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

func NewDeviceTimerInfoRepo

func NewDeviceTimerInfoRepo(in any) *DeviceTimingInfoRepo

func (DeviceTimingInfoRepo) CountByFilter

func (p DeviceTimingInfoRepo) CountByFilter(ctx context.Context, f DeviceTimerInfoFilter) (size int64, err error)

func (DeviceTimingInfoRepo) Delete

func (p DeviceTimingInfoRepo) Delete(ctx context.Context, id int64) error

func (DeviceTimingInfoRepo) DeleteByFilter

func (DeviceTimingInfoRepo) FindByFilter

func (DeviceTimingInfoRepo) FindOne

func (DeviceTimingInfoRepo) FindOneByFilter

func (DeviceTimingInfoRepo) Insert

func (DeviceTimingInfoRepo) MultiInsert

func (p DeviceTimingInfoRepo) MultiInsert(ctx context.Context, data []*UdDeviceTimerInfo) error

批量插入 LightStrategyDevice 记录

func (DeviceTimingInfoRepo) Update

type ExampleFilter

type ExampleFilter struct {
}

type ExampleRepo

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

func NewExampleRepo

func NewExampleRepo(in any) *ExampleRepo

func (ExampleRepo) CountByFilter

func (p ExampleRepo) CountByFilter(ctx context.Context, f ExampleFilter) (size int64, err error)

func (ExampleRepo) Delete

func (p ExampleRepo) Delete(ctx context.Context, id int64) error

func (ExampleRepo) DeleteByFilter

func (p ExampleRepo) DeleteByFilter(ctx context.Context, f ExampleFilter) error

func (ExampleRepo) FindByFilter

func (p ExampleRepo) FindByFilter(ctx context.Context, f ExampleFilter, page *stores.PageInfo) ([]*UdExample, error)

func (ExampleRepo) FindOne

func (p ExampleRepo) FindOne(ctx context.Context, id int64) (*UdExample, error)

func (ExampleRepo) FindOneByFilter

func (p ExampleRepo) FindOneByFilter(ctx context.Context, f ExampleFilter) (*UdExample, error)

func (ExampleRepo) Insert

func (p ExampleRepo) Insert(ctx context.Context, data *UdExample) error

func (ExampleRepo) MultiInsert

func (p ExampleRepo) MultiInsert(ctx context.Context, data []*UdExample) error

批量插入 LightStrategyDevice 记录

func (ExampleRepo) Update

func (p ExampleRepo) Update(ctx context.Context, data *UdExample) error

func (ExampleRepo) UpdateWithField

func (d ExampleRepo) UpdateWithField(ctx context.Context, f ExampleFilter, updates map[string]any) error

type NotifyUser

type NotifyUser struct {
	TargetType def.TargetType
	TargetIDs  []int64
}

type SceneActionFilter

type SceneActionFilter struct {
	SceneID          int64
	Status           scene.Status
	Statuses         []scene.Status
	ProductID        string
	DeviceName       string
	DeviceAreaID     *stores.Cmp
	ActionDeviceType scene.ActionDeviceType
	DeviceSelectType scene.SelectType
}

type SceneActionRepo

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

func NewSceneActionRepo

func NewSceneActionRepo(in any) *SceneActionRepo

func (SceneActionRepo) CountByFilter

func (p SceneActionRepo) CountByFilter(ctx context.Context, f SceneActionFilter) (size int64, err error)

func (SceneActionRepo) Delete

func (p SceneActionRepo) Delete(ctx context.Context, id int64) error

func (SceneActionRepo) DeleteByFilter

func (p SceneActionRepo) DeleteByFilter(ctx context.Context, f SceneActionFilter) error

func (SceneActionRepo) FindByFilter

func (SceneActionRepo) FindOne

func (SceneActionRepo) FindOneByFilter

func (SceneActionRepo) Insert

func (p SceneActionRepo) Insert(ctx context.Context, data *UdSceneThenAction) error

func (SceneActionRepo) MultiInsert

func (p SceneActionRepo) MultiInsert(ctx context.Context, data []*UdSceneThenAction) error

批量插入 LightStrategyDevice 记录

func (SceneActionRepo) Update

func (p SceneActionRepo) Update(ctx context.Context, data *UdSceneThenAction) error

func (SceneActionRepo) UpdateWithField added in v1.1.1

func (d SceneActionRepo) UpdateWithField(ctx context.Context, f SceneActionFilter, updates map[string]any) error

type SceneIfTriggerFilter

type SceneIfTriggerFilter struct {
	ID                  int64
	SceneID             int64
	Status              scene.Status
	Statuses            []scene.Status
	ExecAt              *stores.Cmp
	LastRunTime         *stores.Cmp
	ExecRepeat          *stores.Cmp
	RepeatType          *stores.Cmp
	ExecLoopStart       *stores.Cmp
	ExecLoopEnd         *stores.Cmp
	ExecType            *stores.Cmp
	ExecRepeatStartDate *stores.Cmp
	ExecRepeatEndDate   *stores.Cmp
	Type                string
	ProjectID           *stores.Cmp
	AreaID              *stores.Cmp
	Device              *devices.Core
	DataID              string
	TriggerDeviceType   scene.TriggerDeviceType
	FirstTriggerTime    *stores.Cmp
	StateKeepType       scene.StateKeepType
	StateKeepValue      *stores.Cmp
}

type SceneIfTriggerRepo

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

func NewSceneIfTriggerRepo

func NewSceneIfTriggerRepo(in any) *SceneIfTriggerRepo

func (SceneIfTriggerRepo) CountByFilter

func (p SceneIfTriggerRepo) CountByFilter(ctx context.Context, f SceneIfTriggerFilter) (size int64, err error)

func (SceneIfTriggerRepo) Delete

func (p SceneIfTriggerRepo) Delete(ctx context.Context, id int64) error

func (SceneIfTriggerRepo) DeleteByFilter

func (p SceneIfTriggerRepo) DeleteByFilter(ctx context.Context, f SceneIfTriggerFilter) error

func (SceneIfTriggerRepo) FindByFilter

func (SceneIfTriggerRepo) FindByFilters added in v1.0.2

func (SceneIfTriggerRepo) FindOne

func (SceneIfTriggerRepo) FindOneByFilter

func (SceneIfTriggerRepo) Insert

func (SceneIfTriggerRepo) MultiInsert

func (p SceneIfTriggerRepo) MultiInsert(ctx context.Context, data []*UdSceneIfTrigger) error

批量插入 LightStrategyDevice 记录

func (SceneIfTriggerRepo) Update

func (SceneIfTriggerRepo) UpdateWithField

func (d SceneIfTriggerRepo) UpdateWithField(ctx context.Context, f SceneIfTriggerFilter, updates map[string]any) error

type SceneInfoFilter

type SceneInfoFilter struct {
	Name             string `json:"name"`
	IDs              []int64
	Status           int64
	Type             string
	Tag              string
	IsCommon         def.Bool
	AreaID           int64
	AreaIDs          []int64
	DeviceMode       scene.DeviceMode //设备模式
	ProductID        string           //产品id
	DeviceName       string           //设备名
	DeviceAreaID     int64
	DeviceFilterMode int64 //设备过滤模式: 1,过滤触发或执行(默认) 2,过滤触发 3,过滤执行

	HasActionType string //过滤有某个执行类型
	ProjectID     int64
}

type SceneInfoRepo

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

func NewSceneInfoRepo

func NewSceneInfoRepo(in any) *SceneInfoRepo

func (SceneInfoRepo) CountByFilter

func (p SceneInfoRepo) CountByFilter(ctx context.Context, f SceneInfoFilter) (size int64, err error)

func (SceneInfoRepo) Delete

func (p SceneInfoRepo) Delete(ctx context.Context, id int64) error

func (SceneInfoRepo) DeleteByFilter

func (p SceneInfoRepo) DeleteByFilter(ctx context.Context, f SceneInfoFilter) error

func (SceneInfoRepo) FindByFilter

func (p SceneInfoRepo) FindByFilter(ctx context.Context, f SceneInfoFilter, page *stores.PageInfo) ([]*UdSceneInfo, error)

func (SceneInfoRepo) FindOne

func (p SceneInfoRepo) FindOne(ctx context.Context, id int64) (*UdSceneInfo, error)

func (SceneInfoRepo) FindOneByFilter

func (p SceneInfoRepo) FindOneByFilter(ctx context.Context, f SceneInfoFilter) (*UdSceneInfo, error)

func (SceneInfoRepo) Insert

func (p SceneInfoRepo) Insert(ctx context.Context, data *UdSceneInfo) error

func (SceneInfoRepo) MultiInsert

func (p SceneInfoRepo) MultiInsert(ctx context.Context, data []*UdSceneInfo) error

批量插入 LightStrategyDevice 记录

func (SceneInfoRepo) Update

func (p SceneInfoRepo) Update(ctx context.Context, data *UdSceneInfo) error

func (SceneInfoRepo) UpdateHeadImg

func (p SceneInfoRepo) UpdateHeadImg(ctx context.Context, data *UdSceneInfo) error

func (SceneInfoRepo) UpdateWithField

func (d SceneInfoRepo) UpdateWithField(ctx context.Context, f SceneInfoFilter, updates map[string]any) error

type SceneLogFilter

type SceneLogFilter struct {
	Time          *def.TimeRange
	Status        int64
	SceneID       int64
	SceneName     string
	WithSceneInfo bool
}

type SceneLogRepo

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

func NewSceneLogRepo

func NewSceneLogRepo(in any) *SceneLogRepo

func (SceneLogRepo) CountByFilter

func (p SceneLogRepo) CountByFilter(ctx context.Context, f SceneLogFilter) (size int64, err error)

func (SceneLogRepo) Delete

func (p SceneLogRepo) Delete(ctx context.Context, id int64) error

func (SceneLogRepo) DeleteByFilter

func (p SceneLogRepo) DeleteByFilter(ctx context.Context, f SceneLogFilter) error

func (SceneLogRepo) FindByFilter

func (p SceneLogRepo) FindByFilter(ctx context.Context, f SceneLogFilter, page *stores.PageInfo) ([]*UdSceneLog, error)

func (SceneLogRepo) FindOne

func (p SceneLogRepo) FindOne(ctx context.Context, id int64) (*UdSceneLog, error)

func (SceneLogRepo) FindOneByFilter

func (p SceneLogRepo) FindOneByFilter(ctx context.Context, f SceneLogFilter) (*UdSceneLog, error)

func (SceneLogRepo) Insert

func (p SceneLogRepo) Insert(ctx context.Context, data *UdSceneLog) error

func (SceneLogRepo) MultiInsert

func (p SceneLogRepo) MultiInsert(ctx context.Context, data []*UdSceneLog) error

批量插入 LightStrategyDevice 记录

func (SceneLogRepo) Update

func (p SceneLogRepo) Update(ctx context.Context, data *UdSceneLog) error

func (SceneLogRepo) UpdateWithField

func (d SceneLogRepo) UpdateWithField(ctx context.Context, f SceneLogFilter, updates map[string]any) error

type UdAlarmInfo

type UdAlarmInfo struct {
	ID         int64             `gorm:"column:id;type:BIGINT;primary_key;AUTO_INCREMENT"`
	TenantCode stores.TenantCode `gorm:"column:tenant_code;type:VARCHAR(50);NOT NULL"`     // 租户编码
	ProjectID  stores.ProjectID  `gorm:"column:project_id;type:bigint;default:0;NOT NULL"` // 项目ID(雪花ID)
	Name       string            `gorm:"column:name;type:VARCHAR(100);NOT NULL"`
	Desc       string            `gorm:"column:desc;type:VARCHAR(100);NOT NULL"`
	Level      int64             `gorm:"column:level;type:SMALLINT;default:1"`                   // 告警配置级别(1提醒 2一般 3严重 4紧急 5超紧急)
	Status     int64             `gorm:"column:status;type:SMALLINT;default:1"`                  // 状态 1:启用,2:禁用
	Notifies   []*UdAlarmNotify  `gorm:"column:notifies;type:json;serializer:json;default:'[]'"` // 短信通知模版编码
	UserIDs    []int64           `gorm:"column:user_ids;type:json;serializer:json;default:'[]'"` //指定用户ID
	Accounts   []string          `gorm:"column:accounts;type:json;serializer:json;default:'[]'"` //账号
	Scenes     []*UdAlarmScene   `gorm:"foreignKey:AlarmID;references:ID"`
	stores.Time
}

告警配置信息表

func (*UdAlarmInfo) TableName

func (m *UdAlarmInfo) TableName() string

type UdAlarmNotify

type UdAlarmNotify struct {
	Type       string `json:"type"`       //通知类型
	TemplateID int64  `json:"templateID"` //模版code,不选就是默认的
}

type UdAlarmRecord

type UdAlarmRecord struct {
	ID             int64                   `gorm:"column:id;type:BIGINT;primary_key;AUTO_INCREMENT"`
	TenantCode     stores.TenantCode       `gorm:"column:tenant_code;type:VARCHAR(50);NOT NULL"`       // 租户编码
	ProjectID      stores.ProjectID        `gorm:"column:project_id;type:bigint;default:0;NOT NULL"`   // 项目ID(雪花ID)
	AlarmID        int64                   `gorm:"column:alarm_id;type:BIGINT;NOT NULL"`               //告警记录ID
	AlarmName      string                  `gorm:"column:alarm_name;type:VARCHAR(100);NOT NULL"`       //告警名称
	TriggerType    scene.TriggerType       `gorm:"column:trigger_type;type:VARCHAR(100);NOT NULL"`     //触发类型(设备触发1,其他2)
	TriggerSubType scene.TriggerDeviceType `gorm:"column:trigger_sub_type;type:VARCHAR(100);"`         //触发类型(设备触发1,其他2)
	TriggerDetail  string                  `gorm:"column:trigger_detail;type:VARCHAR(500);default:''"` //触发详情
	ProductID      string                  `gorm:"column:product_id;type:varchar(100);"`               //触发产品id
	DeviceName     string                  `gorm:"column:device_name;type:varchar(100);"`              //触发设备ID
	DeviceAlias    string                  `gorm:"column:device_alias;type:varchar(100);"`             //触发设备名称
	Level          int64                   `gorm:"column:level;type:SMALLINT;NOT NULL"`                //告警配置级别(1提醒 2一般 3严重 4紧急 5超紧急)
	SceneName      string                  `gorm:"column:scene_name;type:varchar(100);NOT NULL"`
	SceneID        int64                   `gorm:"column:scene_id;type:BIGINT;NOT NULL"`
	DealStatus     scene.AlarmDealStatus   `gorm:"column:deal_status;type:SMALLINT;default:1;NOT NULL"` //告警记录状态(1告警中 2已忽略 3已处理)
	Desc           string                  `gorm:"column:desc;type:varchar(100);"`
	WorkOrderID    int64                   `gorm:"column:work_order_id;type:BIGINT;NOT NULL"` //工作流ID
	AlarmCount     int64                   `gorm:"column:alarm_count;type:BIGINT;default:1"`  //告警次数
	LastAlarm      time.Time               `gorm:"column:last_alarm;NOT NULL"`
	CreatedTime    time.Time               `gorm:"column:created_time;default:CURRENT_TIMESTAMP;NOT NULL"`
}

告警记录表 一个告警

func (*UdAlarmRecord) TableName

func (m *UdAlarmRecord) TableName() string

type UdAlarmScene

type UdAlarmScene struct {
	ID         int64             `gorm:"column:id;type:BIGINT;primary_key;AUTO_INCREMENT"`
	TenantCode stores.TenantCode `gorm:"column:tenant_code;type:VARCHAR(50);NOT NULL"`     // 租户编码
	ProjectID  stores.ProjectID  `gorm:"column:project_id;type:bigint;default:0;NOT NULL"` // 项目ID(雪花ID)
	AlarmID    int64             `gorm:"column:alarm_id;uniqueIndex:ai_si;type:BIGINT;NOT NULL"`
	SceneID    int64             `gorm:"column:scene_id;uniqueIndex:ai_si;type:BIGINT;NOT NULL"`
	SceneInfo  *UdSceneInfo      `gorm:"foreignKey:ID;references:SceneID"`
	AlarmInfo  *UdAlarmInfo      `gorm:"foreignKey:ID;references:AlarmID"`
	stores.Time
}

告警配置与场景关联表

func (*UdAlarmScene) TableName

func (m *UdAlarmScene) TableName() string

type UdDeviceTimerInfo

type UdDeviceTimerInfo struct {
	ID          int64             `gorm:"column:id;type:bigint;primary_key;AUTO_INCREMENT"` // id编号
	TenantCode  stores.TenantCode `gorm:"column:tenant_code;type:VARCHAR(50);NOT NULL"`     // 租户编码
	ProjectID   stores.ProjectID  `gorm:"column:project_id;type:bigint;default:0;NOT NULL"` // 项目ID(雪花ID)
	ProductID   string            `gorm:"column:product_id;type:varchar(100);NOT NULL"`     // 产品id
	DeviceName  string            `gorm:"column:device_name;type:varchar(100);NOT NULL"`    // 设备名称
	DeviceAlias string            `gorm:"column:device_alias;type:varchar(100);NOT NULL"`   // 设备名称
	TriggerType string            `gorm:"column:trigger_type;type:varchar(25);NOT NULL"`    //触发类型 timer: 定时触发 delay: 延迟触发(延迟触发同时只能存在一个)
	ExecAt      int64             `gorm:"column:exec_at;type:bigint;NOT NULL"`              //执行时间 从0点加起来的秒数 如 1点就是 1*60*60
	ExecRepeat  int64             `gorm:"column:exec_repeat;type:bigint;default:0b1111111"` //重复 二进制周日到周六 11111111 这个参数只有定时触发才有
	ActionType  string            `gorm:"column:action_type;type:varchar(25);NOT NULL"`     //云端向设备发起属性控制: propertyControl  应用调用设备行为:action
	DataName    string            `gorm:"column:data_name;type:VARCHAR(500);NOT NULL"`      //对应的物模型定义,只读
	DataID      string            `gorm:"column:data_id;type:varchar(100);NOT NULL"`        //属性的id及行为的id
	Value       string            `gorm:"column:value;type:varchar(1024);default:NULL"`     //传的值
	Name        string            `gorm:"column:name;type:varchar(100);default:''"`         // 名称
	LastRunTime time.Time         `gorm:"column:last_run_time;index;default:CURRENT_TIMESTAMP;NOT NULL"`
	Status      int64             `gorm:"column:status;type:BIGINT;default:1"` //状态
	stores.SoftTime
}

func (*UdDeviceTimerInfo) TableName

func (m *UdDeviceTimerInfo) TableName() string

type UdExample

type UdExample struct {
	ID int64 `gorm:"column:id;type:bigint;primary_key;AUTO_INCREMENT"` // id编号
}

示例

type UdSceneActionDevice

type UdSceneActionDevice struct {
	//ProjectID        int64                  `gorm:"column:project_id;type:bigint;default:2;NOT NULL"`  // 项目ID(雪花ID)
	AreaID           int64                  `gorm:"column:area_id;type:bigint;default:2;"` // 项目区域ID(雪花ID)
	AreaName         string                 `gorm:"column:area_name;index;type:VARCHAR(100);default:''"`
	ProductID        string                 `gorm:"column:product_id;index;type:VARCHAR(25);default:''"`    //产品id
	ProductName      string                 `gorm:"column:product_name;index;type:VARCHAR(200);default:''"` //产品id
	SelectType       scene.SelectType       `gorm:"column:select_type;type:VARCHAR(25);default:''"`         //设备选择方式
	DeviceName       string                 `gorm:"column:device_name;type:VARCHAR(255);"`                  //选择的列表  选择的列表, fixed类型是设备名列表
	DeviceAlias      string                 `gorm:"column:device_alias;type:VARCHAR(255);"`                 //设备别名
	GroupID          int64                  `gorm:"column:group_id;index;type:bigint"`                      //group类型传GroupID
	Type             scene.ActionDeviceType `gorm:"column:type;type:VARCHAR(25);default:''"`
	DataID           string                 `gorm:"column:data_id;index;type:VARCHAR(100);default:''"`
	Value            string                 `gorm:"column:value;index;type:VARCHAR(500);default:''"`
	DataName         string                 `gorm:"column:data_name;type:VARCHAR(500);default:''"` //对应的物模型定义,只读
	SchemaAffordance string                 `gorm:"column:schema_affordance;type:VARCHAR(500);default:''"`
	Values           scene.DeviceValues     `gorm:"column:values;type:json;serializer:json"`
	Body             string                 `gorm:"column:body;type:VARCHAR(1024)"` // 自定义数据
}

type UdSceneActionScene

type UdSceneActionScene struct {
	SceneID   int64           `gorm:"column:scene_id;index;type:bigint"` // 场景id编号
	AreaID    int64           `gorm:"column:area_id;type:bigint;"`       // 项目区域ID(雪花ID)
	SceneType scene.SceneType `gorm:"column:scene_type;type:VARCHAR(25);NOT NULL"`
	SceneName string          `gorm:"column:scene_name;type:VARCHAR(256);NOT NULL"`
	Status    def.Bool        `gorm:"column:status;type:BIGINT;default:1"` //状态
}

type UdSceneIf

type UdSceneIf struct {
	Triggers []*UdSceneIfTrigger `gorm:"foreignKey:SceneID;references:ID"`
}

type UdSceneIfTrigger

type UdSceneIfTrigger struct {
	ID              int64                 `gorm:"column:id;type:bigint;primary_key;AUTO_INCREMENT"` // id编号
	Type            scene.TriggerType     `gorm:"column:type;type:VARCHAR(25);NOT NULL"`            //触发类型 device: 设备触发 timer: 定时触发
	SceneID         int64                 `gorm:"column:scene_id;index;type:bigint"`                // 场景id编号
	ProjectID       stores.ProjectID      `gorm:"column:project_id;type:bigint;default:1;"`         // 项目ID(雪花ID)
	AreaID          stores.AreaID         `gorm:"column:area_id;type:bigint;default:1;"`            // 项目区域ID(雪花ID)
	Order           int64                 `gorm:"column:order;type:BIGINT;default:1;NOT NULL"`      // 排序序号
	Status          scene.Status          `gorm:"column:status;type:BIGINT;default:1"`              //状态 同步场景联动的status
	Reason          string                `gorm:"column:reason;type:VARCHAR(255);default:''"`       //异常原因
	LastRunTime     sql.NullTime          `gorm:"column:last_run_time;index;default: NULL"`         //最后执行时间
	LastTriggerTime sql.NullTime          `gorm:"column:last_trigger_time;index;default: NULL"`     //最后触发时间
	Device          UdSceneTriggerDevice  `gorm:"embedded;embeddedPrefix:device_"`
	Timer           UdSceneTriggerTimer   `gorm:"embedded;embeddedPrefix:timer_"`
	Weather         UdSceneTriggerWeather `gorm:"embedded;embeddedPrefix:weather_"`
	SceneInfo       *UdSceneInfo          `gorm:"foreignKey:ID;references:SceneID"`
	stores.SoftTime
}

func (*UdSceneIfTrigger) TableName

func (m *UdSceneIfTrigger) TableName() string

type UdSceneInfo

type UdSceneInfo struct {
	ID          int64             `gorm:"column:id;type:bigint;primary_key;AUTO_INCREMENT"`                       // id编号
	TenantCode  stores.TenantCode `gorm:"column:tenant_code;type:VARCHAR(50);NOT NULL"`                           // 租户编码
	ProjectID   stores.ProjectID  `gorm:"column:project_id;type:bigint;default:0;NOT NULL"`                       // 项目ID(雪花ID)
	AreaID      stores.AreaID     `gorm:"column:area_id;index:project_id_area_id;type:bigint;default:0;NOT NULL"` // 项目区域ID(雪花ID)
	FlowPath    []*scene.FlowInfo `gorm:"column:flow_path;type:json;serializer:json;"`                            //执行路径
	DeviceMode  scene.DeviceMode  `gorm:"column:device_mode;type:VARCHAR(50);default:'single'"`                   //设备模式
	ProductID   string            `gorm:"column:product_id;index;type:VARCHAR(25);default:''"`                    //产品id
	DeviceName  string            `gorm:"column:device_name;type:VARCHAR(255);default:''"`                        //设备名
	DeviceAlias string            `gorm:"column:device_alias;type:VARCHAR(255);default:''"`                       //设备别名
	Tag         string            `gorm:"column:tag;type:VARCHAR(128);NOT NULL;default:normal"`                   //标签 admin: 管理员 normal: 普通
	IsCommon    def.Bool          `gorm:"column:is_common;type:BIGINT;default:2"`                                 //是否是常用的
	HeadImg     string            `gorm:"column:head_img;type:VARCHAR(256);NOT NULL"`                             // 头像
	Name        string            `gorm:"column:name;type:varchar(100);"`                                         // 名称
	Desc        string            `gorm:"column:desc;type:varchar(200);"`                                         // 描述
	Type        scene.SceneType   `gorm:"column:type;type:VARCHAR(25);"`                                          //auto manual
	LastRunTime sql.NullTime      `gorm:"column:last_run_time;index;default:null"`
	Status      def.Bool          `gorm:"column:status;type:BIGINT;default:1"`        //状态
	Reason      string            `gorm:"column:reason;type:VARCHAR(255);default:''"` //异常原因
	Body        string            `gorm:"column:body;type:VARCHAR(1024)"`             // 自定义数据
	UdSceneIf   `gorm:"embedded;embeddedPrefix:if_"`
	UdSceneWhen `gorm:"embedded;embeddedPrefix:when_"`
	UdSceneThen `gorm:"embedded;embeddedPrefix:then_"`
	stores.SoftTime
}

func (*UdSceneInfo) TableName

func (m *UdSceneInfo) TableName() string

type UdSceneLog

type UdSceneLog struct {
	ID         int64              `gorm:"column:id;type:bigint;primary_key;AUTO_INCREMENT"`    // id编号
	TenantCode stores.TenantCode  `gorm:"column:tenant_code;type:VARCHAR(50);NOT NULL"`        // 租户编码
	ProjectID  stores.ProjectID   `gorm:"column:project_id;type:bigint;default:0;NOT NULL"`    // 项目ID(雪花ID)
	AreaID     stores.AreaID      `gorm:"column:area_id;index;type:bigint;default:0;NOT NULL"` // 项目区域ID(雪花ID)
	SceneID    int64              `gorm:"column:scene_id;index;type:bigint;NOT NULL"`          // 项目区域ID(雪花ID)
	Type       scene.SceneType    `gorm:"column:type;type:VARCHAR(25);NOT NULL"`               //auto manual
	Trigger    *scene.LogTrigger  `gorm:"column:trigger;type:json;serializer:json"`
	Actions    []*scene.LogAction `gorm:"column:actions;type:json;serializer:json"`
	Status     def.Bool           `gorm:"column:status;type:BIGINT;default:1"` //状态
	SceneInfo  *UdSceneInfo       `gorm:"foreignKey:ID;references:SceneID"`
	stores.OnlyTime
}

func (*UdSceneLog) TableName

func (m *UdSceneLog) TableName() string

type UdSceneThen

type UdSceneThen struct {
	Actions []*UdSceneThenAction `gorm:"foreignKey:scene_id;references:ID"`
}

type UdSceneThenAction

type UdSceneThenAction struct {
	ID         int64               `gorm:"column:id;type:bigint;primary_key;AUTO_INCREMENT"` // id编号
	TenantCode stores.TenantCode   `gorm:"column:tenant_code;type:VARCHAR(50);NOT NULL"`     // 租户编码
	SceneID    int64               `gorm:"column:scene_id;index;type:bigint"`                // 场景id编号
	Order      int64               `gorm:"column:order;type:BIGINT;default:1;NOT NULL"`      // 排序序号
	Type       scene.ActionType    `gorm:"column:type;type:VARCHAR(25);NOT NULL"`
	Delay      int64               `gorm:"column:delay;type:bigint"`
	Device     UdSceneActionDevice `gorm:"embedded;embeddedPrefix:device_"`
	Notify     *scene.ActionNotify `gorm:"column:notify;type:json;serializer:json"`
	Alarm      *scene.ActionAlarm  `gorm:"column:alarm;type:json;serializer:json"`
	Scene      UdSceneActionScene  `gorm:"embedded;embeddedPrefix:scene_"`
}

func (*UdSceneThenAction) TableName

func (m *UdSceneThenAction) TableName() string

type UdSceneTriggerDevice

type UdSceneTriggerDevice struct {
	ProductID        string                  `gorm:"column:product_id;index;type:VARCHAR(25);default:''"`  //产品id
	ProductName      string                  `gorm:"column:product_name;type:VARCHAR(25);default:''"`      //产品id
	SelectType       scene.SelectType        `gorm:"column:select_type;type:VARCHAR(25);default:''"`       //设备选择方式  all: 全部 fixed:指定的设备
	GroupID          int64                   `gorm:"column:group_id;index;type:bigint;default:0"`          //group类型传GroupID
	DeviceName       string                  `gorm:"column:device_name;type:VARCHAR(255);default:''"`      //选择的列表  选择的列表, fixed类型是设备名列表
	DeviceAlias      string                  `gorm:"column:device_alias;type:VARCHAR(255);default:''"`     //设备别名
	Type             scene.TriggerDeviceType `gorm:"column:type;type:VARCHAR(25);default:''"`              //触发类型  connected:上线 disConnected:下线 reportProperty:属性上报 reportEvent: 事件上报
	DataID           string                  `gorm:"column:data_id;type:VARCHAR(255);default:''"`          //选择为属性或事件时需要填该字段 属性的id及事件的id aa.bb.cc
	DataName         string                  `gorm:"column:data_name;type:VARCHAR(255);default:''"`        //对应的物模型定义,只读
	TermType         string                  `gorm:"column:term_type;type:VARCHAR(255);default:''"`        //动态条件类型  eq: 相等  not:不相等  btw:在xx之间  gt: 大于  gte:大于等于 lt:小于  lte:小于等于   in:在xx值之间
	Values           []string                `gorm:"column:values;type:json;serializer:json;default:'[]'"` //比较条件列表
	SchemaAffordance string                  `gorm:"column:schema_affordance;type:VARCHAR(500);default:''"`
	Body             string                  `gorm:"column:body;type:VARCHAR(1024)"` // 自定义数据
	StateKeep        UdStateKeep             `gorm:"embedded;embeddedPrefix:state_keep_"`
	Terms            scene.Cmps              `gorm:"column:terms;type:json;serializer:json"`        //如果需要多个条件,则可以填写到这里来
	FirstTriggerTime sql.NullTime            `gorm:"column:first_trigger_time;index;default: NULL"` //最后触发时间
}

type UdSceneTriggerTimer

type UdSceneTriggerTimer struct {
	ExecType            scene.ExecType   `gorm:"column:exec_type;type:VARCHAR(25);"`  //执行方式
	ExecAdd             int64            `gorm:"column:exec_add;type:bigint;"`        //如果是日出日落模式,则为日出日落前后的秒数
	ExecAt              int64            `gorm:"column:exec_at;type:bigint;"`         //执行时间 从0点加起来的秒数 如 1点就是 1*60*60
	ExecRepeat          int64            `gorm:"column:exec_repeat;type:bigint;"`     //重复 二进制周日到周六 11111111 这个参数只有定时触发才有
	ExecLoopStart       int64            `gorm:"column:exec_loop_start;type:bigint;"` //循环执行起始时间配置
	ExecLoopEnd         int64            `gorm:"column:exec_loop_end;type:bigint;"`
	ExecLoop            int64            `gorm:"column:exec_loop;type:bigint;"`
	ExecRepeatStartDate sql.NullTime     `gorm:"column:exec_repeat_start_date;index;default:NULL"` //开始日期 2006-01-02
	ExecRepeatEndDate   sql.NullTime     `gorm:"column:exec_repeat_end_date;index;default:NULL"`   //结束日期 2006-01-02
	RepeatType          scene.RepeatType `gorm:"column:repeat_type;type:VARCHAR(25);"`
}

type UdSceneTriggerWeather

type UdSceneTriggerWeather struct {
	Type             scene.WeatherType `gorm:"column:type;type:VARCHAR(25);default:''"`              //天气的类型
	TermType         string            `gorm:"column:term_type;type:VARCHAR(255);default:''"`        //动态条件类型  eq: 相等  not:不相等  btw:在xx之间  gt: 大于  gte:大于等于 lt:小于  lte:小于等于   in:在xx值之间
	Values           []string          `gorm:"column:values;type:json;serializer:json;default:'[]'"` //条件值 参数根据动态条件类型会有多个参数
	FirstTriggerTime sql.NullTime      `gorm:"column:first_trigger_time;index;default: NULL"`        //最后触发时间
}

type UdSceneWhen

type UdSceneWhen struct {
	ValidRanges   scene.WhenRanges `gorm:"column:validRanges;type:json;serializer:json"`
	InvalidRanges scene.WhenRanges `gorm:"column:invalidRanges;type:json;serializer:json"`
	Conditions    scene.Conditions `gorm:"column:conditions;type:json;serializer:json"`
}

type UdStateKeep

type UdStateKeep struct {
	Type  scene.StateKeepType `gorm:"column:type;type:VARCHAR(25);default:''"` //持续时间: duration  重复次数 repeating
	Value int64               `gorm:"column:value;type:bigint;default:0"`      //持续的时间或重复的次数
}

StateKeep 状态保持

Jump to

Keyboard shortcuts

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