2026-08-31 08:06:55 +08:00
|
|
|
package schema
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"entgo.io/ent"
|
|
|
|
|
"entgo.io/ent/dialect/entsql"
|
|
|
|
|
"entgo.io/ent/schema"
|
|
|
|
|
"entgo.io/ent/schema/field"
|
|
|
|
|
"entgo.io/ent/schema/index"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// UserStation 用户-工位 关联(一个操作员可绑定多个工位)
|
|
|
|
|
type UserStation struct {
|
|
|
|
|
ent.Schema
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (UserStation) Annotations() []schema.Annotation {
|
2026-10-08 13:09:53 +08:00
|
|
|
return []schema.Annotation{entsql.Annotation{Table: "user_station"}, entsql.WithComments(true), schema.Comment("UserStation 用户-工位 关联(一个操作员可绑定多个工位)")}
|
2026-08-31 08:06:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (UserStation) Fields() []ent.Field {
|
|
|
|
|
return []ent.Field{
|
|
|
|
|
field.Int("id").Positive(),
|
|
|
|
|
field.Int("userId").Comment("用户ID"),
|
|
|
|
|
field.Int("stationNo").Comment("工位号 1..12"),
|
|
|
|
|
field.Time("createdAt").Default(time.Now).Immutable(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (UserStation) Indexes() []ent.Index {
|
|
|
|
|
return []ent.Index{
|
|
|
|
|
index.Fields("userId"),
|
|
|
|
|
index.Fields("stationNo"),
|
|
|
|
|
index.Fields("userId", "stationNo").Unique(),
|
|
|
|
|
}
|
|
|
|
|
}
|