2026-08-27 10:09:54 +08:00
|
|
|
|
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{
|
2026-08-27 10:56:41 +08:00
|
|
|
|
entsql.Annotation{Table: "signal"},
|
2026-08-27 10:09:54 +08:00
|
|
|
|
entsql.WithComments(true),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (Signal) Fields() []ent.Field {
|
|
|
|
|
|
return []ent.Field{
|
2026-08-27 10:56:41 +08:00
|
|
|
|
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("信号描述"),
|
2026-08-27 10:09:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|