32 lines
840 B
Go
32 lines
840 B
Go
package schema
|
||
|
||
import (
|
||
"entgo.io/ent"
|
||
"entgo.io/ent/dialect/entsql"
|
||
"entgo.io/ent/schema"
|
||
"entgo.io/ent/schema/field"
|
||
)
|
||
|
||
type Signal struct {
|
||
ent.Schema
|
||
}
|
||
|
||
func (Signal) Annotations() []schema.Annotation {
|
||
return []schema.Annotation{
|
||
entsql.Annotation{Table: "signal"},
|
||
entsql.WithComments(true),
|
||
}
|
||
}
|
||
|
||
func (Signal) Fields() []ent.Field {
|
||
return []ent.Field{
|
||
field.Int("id").Positive(),
|
||
field.Int("isStatus").Comment("信号状态(0:任务信号,1:状态信号)"),
|
||
field.String("name").NotEmpty().Unique().Comment("信号名称"),
|
||
field.Int("sender").Default(1).Comment("发送方(1:pc,2:plc)"),
|
||
field.String("address").Comment("PLC地址"),
|
||
field.Int("replyOffset").Default(9).Comment("回复地址偏移量"),
|
||
field.String("description").MaxLen(60).Optional().Comment("信号描述"),
|
||
}
|
||
}
|