Files
bj_power/bj_power_wms/schema/user.go
T
2026-08-28 15:06:01 +08:00

34 lines
901 B
Go

package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// User 用户
type User struct {
ent.Schema
}
func (User) Fields() []ent.Field {
return []ent.Field{
field.String("username").Unique().Comment("登录名"),
field.String("password").Comment("密码(哈希)"),
field.String("real_name").Optional().Comment("姓名"),
field.String("role").Default("operator").Comment("角色 admin/operator/inspector"),
field.String("dept").Optional().Comment("部门"),
field.String("phone").Optional().Comment("电话"),
field.Bool("is_active").Default(true).Comment("是否启用"),
field.Int64("last_login_at").Optional().Comment("最近登录时间"),
field.Int64("created_at").DefaultFunc(nowUnix),
field.Int64("updated_at").DefaultFunc(nowUnix),
}
}
func (User) Indexes() []ent.Index {
return []ent.Index{
index.Fields("role"),
}
}