feat: 添加通知微服务,支持站内通知已读状态
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
)
|
||||
|
||||
type Notifications struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (Notifications) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int64("id").Unique().Immutable(),
|
||||
field.Int64("user_id"),
|
||||
field.String("type").MaxLen(20),
|
||||
field.String("title").MaxLen(200),
|
||||
field.String("content"),
|
||||
field.Bool("read").Default(false),
|
||||
field.String("link").MaxLen(500).Optional().Nillable(),
|
||||
field.Time("created_at").Default(time.Now).Immutable(),
|
||||
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now),
|
||||
}
|
||||
}
|
||||
|
||||
func (Notifications) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("user_id", "created_at"),
|
||||
index.Fields("user_id", "read", "created_at"),
|
||||
index.Fields("user_id", "type", "created_at"),
|
||||
}
|
||||
}
|
||||
|
||||
func (Notifications) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user