-
Notifications
You must be signed in to change notification settings - Fork 7
/
user.go
53 lines (48 loc) · 1.19 KB
/
user.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
// User holds the schema definition for the User entity.
type User struct {
ent.Schema
}
// Fields of the User.
func (User) Fields() []ent.Field {
return []ent.Field{
defaultPrimaryKey(),
field.String("username").
Unique(),
field.String("password"),
field.Enum("status").
Values("active", "blocked"),
field.Enum("type").
Values("admin", "normal", "sentinel"),
field.Time("updated_at").
Default(time.Now).UpdateDefault(time.Now),
field.Time("created_at").
Default(time.Now),
}
}
// Edges of the User.
func (User) Edges() []ent.Edge {
return []ent.Edge{
edge.To("bind_account", Account.Type),
edge.To("purchased_app", AppInfo.Type),
edge.To("app", App.Type),
edge.To("app_inst", AppInst.Type),
edge.To("feed_config", FeedConfig.Type),
edge.To("notify_target", NotifyTarget.Type),
edge.To("notify_flow", NotifyFlow.Type),
edge.To("image", Image.Type),
edge.To("file", File.Type),
edge.To("device_info", DeviceInfo.Type).
Through("user_device", UserDevice.Type),
edge.To("created_user", User.Type).
From("creator").
Unique().
Required(),
}
}