u
This commit is contained in:
1 parent
ac0843c041
commit
a917be08d1
65 files changed
+8043
No files matched your search
@@ -0,0 +1,86 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"cn/oneao/base-go/utils/idgen"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// UserInfo schema.
|
||||
type UserInfo struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Annotations 自定义表名 + 表注释
|
||||
func (UserInfo) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{
|
||||
entsql.Annotation{
|
||||
Table: "user_info",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields 字段定义
|
||||
func (UserInfo) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
|
||||
field.Int64("id").
|
||||
Unique().
|
||||
Immutable().
|
||||
Comment("用户ID").
|
||||
DefaultFunc(idgen.NextId),
|
||||
|
||||
field.Int64("seq_no").
|
||||
Default(0).
|
||||
Comment("序号"),
|
||||
|
||||
field.String("email").
|
||||
Unique().
|
||||
MaxLen(255).
|
||||
Comment("邮箱"),
|
||||
|
||||
field.String("username").
|
||||
NotEmpty().
|
||||
MaxLen(50).
|
||||
Comment("用户名"),
|
||||
|
||||
field.String("password").
|
||||
Sensitive().
|
||||
MaxLen(255).
|
||||
Comment("密码"),
|
||||
|
||||
field.Int64("gender").
|
||||
Default(0).
|
||||
Comment("性别:0未知 1男 2女"),
|
||||
|
||||
field.String("account").
|
||||
Unique().
|
||||
MaxLen(255).
|
||||
Comment("登录账号"),
|
||||
|
||||
// 自动创建时间
|
||||
field.Time("create_time").
|
||||
Default(time.Now).
|
||||
Immutable().
|
||||
Comment("创建时间"),
|
||||
|
||||
// 自动更新时间
|
||||
field.Time("update_time").
|
||||
Default(time.Now).
|
||||
UpdateDefault(time.Now).
|
||||
Comment("更新时间"),
|
||||
|
||||
field.Time("last_login_time").
|
||||
Optional().
|
||||
Nillable().
|
||||
Comment("最近登录时间 (登录后更新)"),
|
||||
}
|
||||
}
|
||||
|
||||
func (UserInfo) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user