-
-
Notifications
You must be signed in to change notification settings - Fork 281
/
token.go
57 lines (49 loc) · 1.23 KB
/
token.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
54
55
56
57
package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"github.com/gofrs/uuid/v5"
"github.com/suyuan32/simple-admin-common/orm/ent/mixins"
)
type Token struct {
ent.Schema
}
func (Token) Fields() []ent.Field {
return []ent.Field{
field.UUID("uuid", uuid.UUID{}).
Comment(" User's UUID | 用户的UUID").
Annotations(entsql.WithComments(true)),
field.String("token").
Comment("Token string | Token 字符串").
Annotations(entsql.WithComments(true)),
field.String("source").
Comment("Log in source such as GitHub | Token 来源 (本地为core, 第三方如github等)").
Annotations(entsql.WithComments(true)),
field.Time("expired_at").
Comment(" Expire time | 过期时间").
Annotations(entsql.WithComments(true)),
}
}
func (Token) Mixin() []ent.Mixin {
return []ent.Mixin{
mixins.UUIDMixin{},
mixins.StatusMixin{},
}
}
func (Token) Edges() []ent.Edge {
return nil
}
func (Token) Indexes() []ent.Index {
return []ent.Index{
index.Fields("uuid"),
index.Fields("expired_at"),
}
}
func (Token) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "sys_tokens"},
}
}