3 Star 0 Fork 0

广东宇凌网络科技有限公司 / simple-iot-data-rpc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
deviceevent.go 6.98 KB
一键复制 编辑 原始数据 按行查看 历史
HienGee 提交于 2024-04-26 11:27 . init
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"gitee.com/yuLingNet/simple-iot-data-rpc/ent/deviceevent"
)
// DeviceEvent is the model entity for the DeviceEvent schema.
type DeviceEvent struct {
config `json:"-"`
// ID of the ent.
ID uint64 `json:"id,omitempty"`
// Create Time | 创建日期
CreatedAt time.Time `json:"created_at,omitempty"`
// Update Time | 修改日期
UpdatedAt time.Time `json:"updated_at,omitempty"`
// Status 1: normal 2: ban | 状态 1 正常 2 禁用
Status uint8 `json:"status,omitempty"`
// Sort Number | 排序编号
Sort uint32 `json:"sort,omitempty"`
// Iot Id | 设备ID
IotID string `json:"iotID,omitempty"`
// EventType | 事件类型,INFO_EVENT_TYPE:信息。ALERT_EVENT_TYPE:告警。ERROR_EVENT_TYPE:故障。
EventType string `json:"eventType,omitempty"`
// Identifier | 事件的标识符
Identifier string `json:"identifier,omitempty"`
// Name | 事件名称
Name string `json:"name,omitempty"`
// Output data | 事件的输出参数
OutputData string `json:"outputData,omitempty"`
// Time | 事件发生时间。毫秒级时间戳。
Time string `json:"time,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*DeviceEvent) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case deviceevent.FieldID, deviceevent.FieldStatus, deviceevent.FieldSort:
values[i] = new(sql.NullInt64)
case deviceevent.FieldIotID, deviceevent.FieldEventType, deviceevent.FieldIdentifier, deviceevent.FieldName, deviceevent.FieldOutputData, deviceevent.FieldTime:
values[i] = new(sql.NullString)
case deviceevent.FieldCreatedAt, deviceevent.FieldUpdatedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the DeviceEvent fields.
func (de *DeviceEvent) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case deviceevent.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
de.ID = uint64(value.Int64)
case deviceevent.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
de.CreatedAt = value.Time
}
case deviceevent.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
de.UpdatedAt = value.Time
}
case deviceevent.FieldStatus:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
de.Status = uint8(value.Int64)
}
case deviceevent.FieldSort:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field sort", values[i])
} else if value.Valid {
de.Sort = uint32(value.Int64)
}
case deviceevent.FieldIotID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field iotID", values[i])
} else if value.Valid {
de.IotID = value.String
}
case deviceevent.FieldEventType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field eventType", values[i])
} else if value.Valid {
de.EventType = value.String
}
case deviceevent.FieldIdentifier:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field identifier", values[i])
} else if value.Valid {
de.Identifier = value.String
}
case deviceevent.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
de.Name = value.String
}
case deviceevent.FieldOutputData:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field outputData", values[i])
} else if value.Valid {
de.OutputData = value.String
}
case deviceevent.FieldTime:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field time", values[i])
} else if value.Valid {
de.Time = value.String
}
default:
de.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the DeviceEvent.
// This includes values selected through modifiers, order, etc.
func (de *DeviceEvent) Value(name string) (ent.Value, error) {
return de.selectValues.Get(name)
}
// Update returns a builder for updating this DeviceEvent.
// Note that you need to call DeviceEvent.Unwrap() before calling this method if this DeviceEvent
// was returned from a transaction, and the transaction was committed or rolled back.
func (de *DeviceEvent) Update() *DeviceEventUpdateOne {
return NewDeviceEventClient(de.config).UpdateOne(de)
}
// Unwrap unwraps the DeviceEvent entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (de *DeviceEvent) Unwrap() *DeviceEvent {
_tx, ok := de.config.driver.(*txDriver)
if !ok {
panic("ent: DeviceEvent is not a transactional entity")
}
de.config.driver = _tx.drv
return de
}
// String implements the fmt.Stringer.
func (de *DeviceEvent) String() string {
var builder strings.Builder
builder.WriteString("DeviceEvent(")
builder.WriteString(fmt.Sprintf("id=%v, ", de.ID))
builder.WriteString("created_at=")
builder.WriteString(de.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(de.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", de.Status))
builder.WriteString(", ")
builder.WriteString("sort=")
builder.WriteString(fmt.Sprintf("%v", de.Sort))
builder.WriteString(", ")
builder.WriteString("iotID=")
builder.WriteString(de.IotID)
builder.WriteString(", ")
builder.WriteString("eventType=")
builder.WriteString(de.EventType)
builder.WriteString(", ")
builder.WriteString("identifier=")
builder.WriteString(de.Identifier)
builder.WriteString(", ")
builder.WriteString("name=")
builder.WriteString(de.Name)
builder.WriteString(", ")
builder.WriteString("outputData=")
builder.WriteString(de.OutputData)
builder.WriteString(", ")
builder.WriteString("time=")
builder.WriteString(de.Time)
builder.WriteByte(')')
return builder.String()
}
// DeviceEvents is a parsable slice of DeviceEvent.
type DeviceEvents []*DeviceEvent
Go
1
https://gitee.com/yuLingNet/simple-iot-data-rpc.git
git@gitee.com:yuLingNet/simple-iot-data-rpc.git
yuLingNet
simple-iot-data-rpc
simple-iot-data-rpc
39cb53be4684

搜索帮助