3 Star 0 Fork 0

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

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
product.go 15.55 KB
一键复制 编辑 原始数据 按行查看 历史
HienGee 提交于 2024-04-26 11:19 . 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-basic-rpc/ent/product"
uuid "github.com/gofrs/uuid/v5"
)
// Product is the model entity for the Product schema.
type Product struct {
config `json:"-"`
// ID of the ent.
// UUID
ID uuid.UUID `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"`
// Product Key | 产品Key
ProductKey string `json:"productKey,omitempty"`
// Product Name | 产品名称
ProductName string `json:"productName,omitempty"`
// Auth Type | 认证方式[secret,id2,x509]
AuthType string `json:"authType,omitempty"`
// Data Format | 数据通信协议类型[0:透传模式。1:Alink JSON。]
DataFormat int32 `json:"dataFormat,omitempty"`
// Description | 产品描述
Description string `json:"description,omitempty"`
// Device Count | 设备数量
DeviceCount int32 `json:"deviceCount,omitempty"`
// GMT Create | GMT创建时间
GmtCreate int64 `json:"gmtCreate,omitempty"`
// Node Type | 节点类型[0:设备。1:网关]
NodeType int32 `json:"nodeType,omitempty"`
// Commodity Code | 产品类型,决定是否使用物模型功能。iothub_senior:使用物模型。iothub:不使用物模型。
AliyunCommodityCode string `json:"aliyunCommodityCode,omitempty"`
// Category Key | 所属品类标识
CategoryKey string `json:"categoryKey,omitempty"`
// Category Name | 所属品类名称
CategoryName string `json:"categoryName,omitempty"`
// ID² | 该产品是否使用ID²认证
Id2 bool `json:"id2,omitempty"`
// Net Type | 产品下设备的联网方式
NetType int32 `json:"netType,omitempty"`
// Owner | 产品下设备的联网方式
Owner bool `json:"owner,omitempty"`
// Product Secret | 产品密钥
ProductSecret string `json:"productSecret,omitempty"`
// Product Status | 产品状态
ProductStatus string `json:"productStatus,omitempty"`
// Protocol Type | 子设备接入网关的协议类型
ProtocolType string `json:"protocolType,omitempty"`
// Validate Type | 数据校验级别
ValidateType int32 `json:"validateType,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the ProductQuery when eager-loading is set.
Edges ProductEdges `json:"edges"`
selectValues sql.SelectValues
}
// ProductEdges holds the relations/edges for other nodes in the graph.
type ProductEdges struct {
// Devices holds the value of the devices edge.
Devices []*Device `json:"devices,omitempty"`
// Tags holds the value of the tags edge.
Tags []*ProductTag `json:"tags,omitempty"`
// Properties holds the value of the properties edge.
Properties []*ProductProperty `json:"properties,omitempty"`
// Events holds the value of the events edge.
Events []*ProductEvent `json:"events,omitempty"`
// Services holds the value of the services edge.
Services []*ProductService `json:"services,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [5]bool
}
// DevicesOrErr returns the Devices value or an error if the edge
// was not loaded in eager-loading.
func (e ProductEdges) DevicesOrErr() ([]*Device, error) {
if e.loadedTypes[0] {
return e.Devices, nil
}
return nil, &NotLoadedError{edge: "devices"}
}
// TagsOrErr returns the Tags value or an error if the edge
// was not loaded in eager-loading.
func (e ProductEdges) TagsOrErr() ([]*ProductTag, error) {
if e.loadedTypes[1] {
return e.Tags, nil
}
return nil, &NotLoadedError{edge: "tags"}
}
// PropertiesOrErr returns the Properties value or an error if the edge
// was not loaded in eager-loading.
func (e ProductEdges) PropertiesOrErr() ([]*ProductProperty, error) {
if e.loadedTypes[2] {
return e.Properties, nil
}
return nil, &NotLoadedError{edge: "properties"}
}
// EventsOrErr returns the Events value or an error if the edge
// was not loaded in eager-loading.
func (e ProductEdges) EventsOrErr() ([]*ProductEvent, error) {
if e.loadedTypes[3] {
return e.Events, nil
}
return nil, &NotLoadedError{edge: "events"}
}
// ServicesOrErr returns the Services value or an error if the edge
// was not loaded in eager-loading.
func (e ProductEdges) ServicesOrErr() ([]*ProductService, error) {
if e.loadedTypes[4] {
return e.Services, nil
}
return nil, &NotLoadedError{edge: "services"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Product) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case product.FieldId2, product.FieldOwner:
values[i] = new(sql.NullBool)
case product.FieldStatus, product.FieldSort, product.FieldDataFormat, product.FieldDeviceCount, product.FieldGmtCreate, product.FieldNodeType, product.FieldNetType, product.FieldValidateType:
values[i] = new(sql.NullInt64)
case product.FieldProductKey, product.FieldProductName, product.FieldAuthType, product.FieldDescription, product.FieldAliyunCommodityCode, product.FieldCategoryKey, product.FieldCategoryName, product.FieldProductSecret, product.FieldProductStatus, product.FieldProtocolType:
values[i] = new(sql.NullString)
case product.FieldCreatedAt, product.FieldUpdatedAt:
values[i] = new(sql.NullTime)
case product.FieldID:
values[i] = new(uuid.UUID)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Product fields.
func (pr *Product) 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 product.FieldID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field id", values[i])
} else if value != nil {
pr.ID = *value
}
case product.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 {
pr.CreatedAt = value.Time
}
case product.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 {
pr.UpdatedAt = value.Time
}
case product.FieldStatus:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
pr.Status = uint8(value.Int64)
}
case product.FieldSort:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field sort", values[i])
} else if value.Valid {
pr.Sort = uint32(value.Int64)
}
case product.FieldProductKey:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field productKey", values[i])
} else if value.Valid {
pr.ProductKey = value.String
}
case product.FieldProductName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field productName", values[i])
} else if value.Valid {
pr.ProductName = value.String
}
case product.FieldAuthType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field authType", values[i])
} else if value.Valid {
pr.AuthType = value.String
}
case product.FieldDataFormat:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field dataFormat", values[i])
} else if value.Valid {
pr.DataFormat = int32(value.Int64)
}
case product.FieldDescription:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field description", values[i])
} else if value.Valid {
pr.Description = value.String
}
case product.FieldDeviceCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field deviceCount", values[i])
} else if value.Valid {
pr.DeviceCount = int32(value.Int64)
}
case product.FieldGmtCreate:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field gmtCreate", values[i])
} else if value.Valid {
pr.GmtCreate = value.Int64
}
case product.FieldNodeType:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field nodeType", values[i])
} else if value.Valid {
pr.NodeType = int32(value.Int64)
}
case product.FieldAliyunCommodityCode:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field aliyunCommodityCode", values[i])
} else if value.Valid {
pr.AliyunCommodityCode = value.String
}
case product.FieldCategoryKey:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field categoryKey", values[i])
} else if value.Valid {
pr.CategoryKey = value.String
}
case product.FieldCategoryName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field categoryName", values[i])
} else if value.Valid {
pr.CategoryName = value.String
}
case product.FieldId2:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field id2", values[i])
} else if value.Valid {
pr.Id2 = value.Bool
}
case product.FieldNetType:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field netType", values[i])
} else if value.Valid {
pr.NetType = int32(value.Int64)
}
case product.FieldOwner:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field owner", values[i])
} else if value.Valid {
pr.Owner = value.Bool
}
case product.FieldProductSecret:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field productSecret", values[i])
} else if value.Valid {
pr.ProductSecret = value.String
}
case product.FieldProductStatus:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field productStatus", values[i])
} else if value.Valid {
pr.ProductStatus = value.String
}
case product.FieldProtocolType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field protocolType", values[i])
} else if value.Valid {
pr.ProtocolType = value.String
}
case product.FieldValidateType:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field validateType", values[i])
} else if value.Valid {
pr.ValidateType = int32(value.Int64)
}
default:
pr.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Product.
// This includes values selected through modifiers, order, etc.
func (pr *Product) Value(name string) (ent.Value, error) {
return pr.selectValues.Get(name)
}
// QueryDevices queries the "devices" edge of the Product entity.
func (pr *Product) QueryDevices() *DeviceQuery {
return NewProductClient(pr.config).QueryDevices(pr)
}
// QueryTags queries the "tags" edge of the Product entity.
func (pr *Product) QueryTags() *ProductTagQuery {
return NewProductClient(pr.config).QueryTags(pr)
}
// QueryProperties queries the "properties" edge of the Product entity.
func (pr *Product) QueryProperties() *ProductPropertyQuery {
return NewProductClient(pr.config).QueryProperties(pr)
}
// QueryEvents queries the "events" edge of the Product entity.
func (pr *Product) QueryEvents() *ProductEventQuery {
return NewProductClient(pr.config).QueryEvents(pr)
}
// QueryServices queries the "services" edge of the Product entity.
func (pr *Product) QueryServices() *ProductServiceQuery {
return NewProductClient(pr.config).QueryServices(pr)
}
// Update returns a builder for updating this Product.
// Note that you need to call Product.Unwrap() before calling this method if this Product
// was returned from a transaction, and the transaction was committed or rolled back.
func (pr *Product) Update() *ProductUpdateOne {
return NewProductClient(pr.config).UpdateOne(pr)
}
// Unwrap unwraps the Product 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 (pr *Product) Unwrap() *Product {
_tx, ok := pr.config.driver.(*txDriver)
if !ok {
panic("ent: Product is not a transactional entity")
}
pr.config.driver = _tx.drv
return pr
}
// String implements the fmt.Stringer.
func (pr *Product) String() string {
var builder strings.Builder
builder.WriteString("Product(")
builder.WriteString(fmt.Sprintf("id=%v, ", pr.ID))
builder.WriteString("created_at=")
builder.WriteString(pr.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(pr.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", pr.Status))
builder.WriteString(", ")
builder.WriteString("sort=")
builder.WriteString(fmt.Sprintf("%v", pr.Sort))
builder.WriteString(", ")
builder.WriteString("productKey=")
builder.WriteString(pr.ProductKey)
builder.WriteString(", ")
builder.WriteString("productName=")
builder.WriteString(pr.ProductName)
builder.WriteString(", ")
builder.WriteString("authType=")
builder.WriteString(pr.AuthType)
builder.WriteString(", ")
builder.WriteString("dataFormat=")
builder.WriteString(fmt.Sprintf("%v", pr.DataFormat))
builder.WriteString(", ")
builder.WriteString("description=")
builder.WriteString(pr.Description)
builder.WriteString(", ")
builder.WriteString("deviceCount=")
builder.WriteString(fmt.Sprintf("%v", pr.DeviceCount))
builder.WriteString(", ")
builder.WriteString("gmtCreate=")
builder.WriteString(fmt.Sprintf("%v", pr.GmtCreate))
builder.WriteString(", ")
builder.WriteString("nodeType=")
builder.WriteString(fmt.Sprintf("%v", pr.NodeType))
builder.WriteString(", ")
builder.WriteString("aliyunCommodityCode=")
builder.WriteString(pr.AliyunCommodityCode)
builder.WriteString(", ")
builder.WriteString("categoryKey=")
builder.WriteString(pr.CategoryKey)
builder.WriteString(", ")
builder.WriteString("categoryName=")
builder.WriteString(pr.CategoryName)
builder.WriteString(", ")
builder.WriteString("id2=")
builder.WriteString(fmt.Sprintf("%v", pr.Id2))
builder.WriteString(", ")
builder.WriteString("netType=")
builder.WriteString(fmt.Sprintf("%v", pr.NetType))
builder.WriteString(", ")
builder.WriteString("owner=")
builder.WriteString(fmt.Sprintf("%v", pr.Owner))
builder.WriteString(", ")
builder.WriteString("productSecret=")
builder.WriteString(pr.ProductSecret)
builder.WriteString(", ")
builder.WriteString("productStatus=")
builder.WriteString(pr.ProductStatus)
builder.WriteString(", ")
builder.WriteString("protocolType=")
builder.WriteString(pr.ProtocolType)
builder.WriteString(", ")
builder.WriteString("validateType=")
builder.WriteString(fmt.Sprintf("%v", pr.ValidateType))
builder.WriteByte(')')
return builder.String()
}
// Products is a parsable slice of Product.
type Products []*Product
Go
1
https://gitee.com/yuLingNet/simple-iot-basic-rpc.git
git@gitee.com:yuLingNet/simple-iot-basic-rpc.git
yuLingNet
simple-iot-basic-rpc
simple-iot-basic-rpc
0ce7f3c9409c

搜索帮助