3 Star 0 Fork 0

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

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
deviceofflinetime.go 6.33 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/deviceofflinetime"
)
// DeviceOfflineTime is the model entity for the DeviceOfflineTime schema.
type DeviceOfflineTime 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"`
// Device Name | 设备名称
DeviceName string `json:"deviceName,omitempty"`
// Product Key | 产品Key
ProductKey string `json:"productKey,omitempty"`
// Time | 离线时间
Time string `json:"time,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*DeviceOfflineTime) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case deviceofflinetime.FieldID, deviceofflinetime.FieldStatus, deviceofflinetime.FieldSort:
values[i] = new(sql.NullInt64)
case deviceofflinetime.FieldIotID, deviceofflinetime.FieldDeviceName, deviceofflinetime.FieldProductKey, deviceofflinetime.FieldTime:
values[i] = new(sql.NullString)
case deviceofflinetime.FieldCreatedAt, deviceofflinetime.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 DeviceOfflineTime fields.
func (dot *DeviceOfflineTime) 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 deviceofflinetime.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
dot.ID = uint64(value.Int64)
case deviceofflinetime.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 {
dot.CreatedAt = value.Time
}
case deviceofflinetime.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 {
dot.UpdatedAt = value.Time
}
case deviceofflinetime.FieldStatus:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
dot.Status = uint8(value.Int64)
}
case deviceofflinetime.FieldSort:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field sort", values[i])
} else if value.Valid {
dot.Sort = uint32(value.Int64)
}
case deviceofflinetime.FieldIotID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field iotID", values[i])
} else if value.Valid {
dot.IotID = value.String
}
case deviceofflinetime.FieldDeviceName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field deviceName", values[i])
} else if value.Valid {
dot.DeviceName = value.String
}
case deviceofflinetime.FieldProductKey:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field productKey", values[i])
} else if value.Valid {
dot.ProductKey = value.String
}
case deviceofflinetime.FieldTime:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field time", values[i])
} else if value.Valid {
dot.Time = value.String
}
default:
dot.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the DeviceOfflineTime.
// This includes values selected through modifiers, order, etc.
func (dot *DeviceOfflineTime) Value(name string) (ent.Value, error) {
return dot.selectValues.Get(name)
}
// Update returns a builder for updating this DeviceOfflineTime.
// Note that you need to call DeviceOfflineTime.Unwrap() before calling this method if this DeviceOfflineTime
// was returned from a transaction, and the transaction was committed or rolled back.
func (dot *DeviceOfflineTime) Update() *DeviceOfflineTimeUpdateOne {
return NewDeviceOfflineTimeClient(dot.config).UpdateOne(dot)
}
// Unwrap unwraps the DeviceOfflineTime 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 (dot *DeviceOfflineTime) Unwrap() *DeviceOfflineTime {
_tx, ok := dot.config.driver.(*txDriver)
if !ok {
panic("ent: DeviceOfflineTime is not a transactional entity")
}
dot.config.driver = _tx.drv
return dot
}
// String implements the fmt.Stringer.
func (dot *DeviceOfflineTime) String() string {
var builder strings.Builder
builder.WriteString("DeviceOfflineTime(")
builder.WriteString(fmt.Sprintf("id=%v, ", dot.ID))
builder.WriteString("created_at=")
builder.WriteString(dot.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(dot.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", dot.Status))
builder.WriteString(", ")
builder.WriteString("sort=")
builder.WriteString(fmt.Sprintf("%v", dot.Sort))
builder.WriteString(", ")
builder.WriteString("iotID=")
builder.WriteString(dot.IotID)
builder.WriteString(", ")
builder.WriteString("deviceName=")
builder.WriteString(dot.DeviceName)
builder.WriteString(", ")
builder.WriteString("productKey=")
builder.WriteString(dot.ProductKey)
builder.WriteString(", ")
builder.WriteString("time=")
builder.WriteString(dot.Time)
builder.WriteByte(')')
return builder.String()
}
// DeviceOfflineTimes is a parsable slice of DeviceOfflineTime.
type DeviceOfflineTimes []*DeviceOfflineTime
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

搜索帮助