schemaDataRepo

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PropertyType = "property_type"
)

Variables

View Source
var TableNames []string

Functions

func GetArrayID

func GetArrayID(id string, num int) string

func NewDeviceDataRepo

func NewDeviceDataRepo(dataSource conf.TSDB, getProductSchemaModel schema.GetSchemaModel, getDeviceSchemaModel schema.GetSchemaModel, kv kv.Store) msgThing.SchemaDataRepo

func ToEventData

func ToEventData(db map[string]any) *msgThing.EventData

func ToPropertyData

func ToPropertyData(id string, p *schema.Property, db map[string]any) *msgThing.PropertyData

Types

type DeviceDataRepo

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

func (*DeviceDataRepo) CreateProperty

func (d *DeviceDataRepo) CreateProperty(ctx context.Context, p *schema.Property, productID string) error

func (*DeviceDataRepo) DeleteDevice

func (d *DeviceDataRepo) DeleteDevice(
	ctx context.Context,
	t *schema.Model,
	productID string,
	deviceName string) error

func (*DeviceDataRepo) DeleteDeviceProperty

func (d *DeviceDataRepo) DeleteDeviceProperty(ctx context.Context, productID string, deviceName string, s []schema.Property) error

func (*DeviceDataRepo) DeleteProduct

func (d *DeviceDataRepo) DeleteProduct(ctx context.Context, t *schema.Model, productID string) error

func (*DeviceDataRepo) DeleteProperty

func (d *DeviceDataRepo) DeleteProperty(ctx context.Context, p *schema.Property, productID string, identifier string) error

func (*DeviceDataRepo) GenInsertPropertySql

func (d *DeviceDataRepo) GenInsertPropertySql(ctx context.Context, p *schema.Property, productID string, deviceName string,
	property *msgThing.Param, timestamp time.Time, optional msgThing.Optional) (err error)

func (*DeviceDataRepo) GetEventCountByFilter

func (d *DeviceDataRepo) GetEventCountByFilter(
	ctx context.Context,
	filter msgThing.FilterOpt) (int64, error)

func (*DeviceDataRepo) GetEventDataByFilter

func (d *DeviceDataRepo) GetEventDataByFilter(
	ctx context.Context,
	filter msgThing.FilterOpt) ([]*msgThing.EventData, error)

func (*DeviceDataRepo) GetLatestPropertyDataByID

func (d *DeviceDataRepo) GetLatestPropertyDataByID(ctx context.Context, p *schema.Property, filter msgThing.LatestFilter) (*msgThing.PropertyData, error)

func (*DeviceDataRepo) GetPropertyCountByID

func (d *DeviceDataRepo) GetPropertyCountByID(
	ctx context.Context, p *schema.Property,
	filter msgThing.FilterOpt) (int64, error)

func (*DeviceDataRepo) GetPropertyDataByID

func (d *DeviceDataRepo) GetPropertyDataByID(
	ctx context.Context, p *schema.Property,
	filter msgThing.FilterOpt) ([]*msgThing.PropertyData, error)

func (*DeviceDataRepo) Init

func (d *DeviceDataRepo) Init(ctx context.Context) error

func (*DeviceDataRepo) InitDevice

func (d *DeviceDataRepo) InitDevice(ctx context.Context,
	t *schema.Model,
	productID string,
	deviceName string) error

func (*DeviceDataRepo) InitProduct

func (d *DeviceDataRepo) InitProduct(ctx context.Context, t *schema.Model, productID string) error

func (*DeviceDataRepo) InsertEventData

func (d *DeviceDataRepo) InsertEventData(ctx context.Context, productID string,
	deviceName string, event *msgThing.EventData) error

func (*DeviceDataRepo) InsertPropertiesData

func (d *DeviceDataRepo) InsertPropertiesData(ctx context.Context, t *schema.Model, productID string, deviceName string,
	params map[string]msgThing.Param, timestamp time.Time, optional msgThing.Optional) error

func (*DeviceDataRepo) InsertPropertyData

func (d *DeviceDataRepo) InsertPropertyData(ctx context.Context, t *schema.Property, productID string, deviceName string,
	property *msgThing.Param, timestamp time.Time, optional msgThing.Optional) error

func (*DeviceDataRepo) UpdateProperty

func (d *DeviceDataRepo) UpdateProperty(
	ctx context.Context,
	oldP *schema.Property,
	newP *schema.Property,
	productID string) error

type Event

type Event struct {
	ProductID  string    `gorm:"column:product_id;type:varchar(100);NOT NULL"`  // 产品id
	DeviceName string    `gorm:"column:device_name;type:varchar(100);NOT NULL"` // 设备名称
	Identifier string    `gorm:"column:identifier;type:varchar(100);NOT NULL"`  // 事件id
	Type       string    `gorm:"column:type;type:varchar(100);NOT NULL"`        // 事件内容
	Param      string    `gorm:"column:param;type:varchar(256);NOT NULL"`       // 时间戳
	Timestamp  time.Time `gorm:"column:ts;NOT NULL;"`                           // 操作时间
}

func (*Event) TableName

func (m *Event) TableName() string

type Property

type Property struct {
	ProductID  string    `gorm:"column:product_id;type:varchar(100);NOT NULL"`  // 产品id
	DeviceName string    `gorm:"column:device_name;type:varchar(100);NOT NULL"` // 设备名称
	Timestamp  time.Time `gorm:"column:ts;NOT NULL;"`                           // 操作时间
	Identifier string    `gorm:"column:identifier;type:varchar(100);NOT NULL"`  // 事件id
}

type PropertyBool

type PropertyBool struct {
	Property
	Param bool `gorm:"column:param;NOT NULL"` // 时间戳
}

func (*PropertyBool) TableName

func (m *PropertyBool) TableName() string

type PropertyBoolArray

type PropertyBoolArray struct {
	Property
	Param bool  `gorm:"column:param;NOT NULL"` // 时间戳
	Pos   int64 `gorm:"column:pos;NOT NULL;"`
}

func (*PropertyBoolArray) TableName

func (m *PropertyBoolArray) TableName() string

type PropertyEnum

type PropertyEnum struct {
	Property
	Param int64 `gorm:"column:param;NOT NULL"` // 时间戳
}

func (*PropertyEnum) TableName

func (m *PropertyEnum) TableName() string

type PropertyEnumArray

type PropertyEnumArray struct {
	Property
	Param int64 `gorm:"column:param;NOT NULL"` // 时间戳
	Pos   int64 `gorm:"column:pos;NOT NULL;"`
}

func (*PropertyEnumArray) TableName

func (m *PropertyEnumArray) TableName() string

type PropertyFloat

type PropertyFloat struct {
	Property
	Param float64 `gorm:"column:param;NOT NULL"` // 时间戳
}

func (*PropertyFloat) TableName

func (m *PropertyFloat) TableName() string

type PropertyFloatArray

type PropertyFloatArray struct {
	Property
	Param float64 `gorm:"column:param;NOT NULL"` // 时间戳
	Pos   int64   `gorm:"column:pos;NOT NULL;"`
}

func (*PropertyFloatArray) TableName

func (m *PropertyFloatArray) TableName() string

type PropertyInt

type PropertyInt struct {
	Property
	Param int64 `gorm:"column:param;NOT NULL"` // 时间戳
}

func (*PropertyInt) TableName

func (m *PropertyInt) TableName() string

type PropertyIntArray

type PropertyIntArray struct {
	Property
	Param int64 `gorm:"column:param;NOT NULL"` // 时间戳
	Pos   int64 `gorm:"column:pos;NOT NULL;"`
}

func (*PropertyIntArray) TableName

func (m *PropertyIntArray) TableName() string

type PropertyString

type PropertyString struct {
	Property
	Param string `gorm:"column:param;type:varchar(256);NOT NULL"` // 时间戳
}

func (*PropertyString) TableName

func (m *PropertyString) TableName() string

type PropertyStringArray

type PropertyStringArray struct {
	Property
	Param string `gorm:"column:param;type:varchar(256);NOT NULL"` // 时间戳
	Pos   int64  `gorm:"column:pos;NOT NULL;"`
}

func (*PropertyStringArray) TableName

func (m *PropertyStringArray) TableName() string

type PropertyStruct

type PropertyStruct struct {
	Property
	Param map[string]any `gorm:"column:param;type:json;serializer:json;NOT NULL"` // 时间戳
}

func (*PropertyStruct) TableName

func (m *PropertyStruct) TableName() string

type PropertyStructArray

type PropertyStructArray struct {
	Property
	Param map[string]any `gorm:"column:param;type:json;serializer:json;NOT NULL"` // 时间戳
	Pos   int64          `gorm:"column:pos;NOT NULL;"`
}

func (*PropertyStructArray) TableName

func (m *PropertyStructArray) TableName() string

type PropertyTimestamp

type PropertyTimestamp struct {
	Property
	Param int64 `gorm:"column:param;NOT NULL"` // 时间戳
}

func (*PropertyTimestamp) TableName

func (m *PropertyTimestamp) TableName() string

type PropertyTimestampArray

type PropertyTimestampArray struct {
	Property
	Param int64 `gorm:"column:param;NOT NULL"` // 时间戳
	Pos   int64 `gorm:"column:pos;NOT NULL;"`
}

func (*PropertyTimestampArray) TableName

func (m *PropertyTimestampArray) TableName() string

Jump to

Keyboard shortcuts

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