2 Star 0 Fork 0

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

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
product_event.go 2.33 KB
一键复制 编辑 原始数据 按行查看 历史
HienGee 提交于 2024-04-26 11:19 . init
package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"github.com/suyuan32/simple-admin-common/orm/ent/mixins"
)
// ProductEvent holds the schema definition for the ProductEvent entity.
type ProductEvent struct {
ent.Schema
}
// Fields of the ProductEvent.
func (ProductEvent) Fields() []ent.Field {
return []ent.Field{
field.String("productKey").
Comment("Product Key | 产品Key").
Annotations(entsql.WithComments(true)),
field.Int64("createTs").
Optional().
Comment("CreateTs | 功能创建的时间戳").
Annotations(entsql.WithComments(true)),
field.String("version").
Optional().
Comment("Version | 物模型版本号").
Annotations(entsql.WithComments(true)),
field.String("identifier").
Comment("Identifier | 事件的标识符").
Annotations(entsql.WithComments(true)),
field.String("eventName").
Comment("EventName | 事件名称").
Annotations(entsql.WithComments(true)),
field.String("eventType").
Optional().
Default("INFO_EVENT_TYPE").
Comment("EventType | 事件类型,INFO_EVENT_TYPE:信息。ALERT_EVENT_TYPE:告警。ERROR_EVENT_TYPE:故障。").
Annotations(entsql.WithComments(true)),
field.Text("outputData").
Optional().
Comment("Output data | 事件的输出参数").
Annotations(entsql.WithComments(true)),
field.Bool("custom").
Default(true).
Comment("Custom | 是否是自定义功能").
Annotations(entsql.WithComments(true)),
field.Bool("required").
Default(false).
Comment("Required | 是否是标准品类的必选事件").
Annotations(entsql.WithComments(true)),
}
}
// Edges of the ProductEvent.
func (ProductEvent) Edges() []ent.Edge {
return []ent.Edge{
edge.From("product", Product.Type).Ref("events").Unique(),
}
}
// Mixin of the ProductEvent.
func (ProductEvent) Mixin() []ent.Mixin {
return []ent.Mixin{
mixins.IDMixin{},
mixins.StatusMixin{},
mixins.SortMixin{},
}
}
// Indexes of the ProductEvent.
func (ProductEvent) Indexes() []ent.Index {
return []ent.Index{
index.Fields("productKey", "identifier").Unique(),
}
}
// Annotations of the ProductEvent
func (ProductEvent) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "equip_product_events"},
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
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
ca5a4cf0cee7

搜索帮助