feat: 添加搜索收藏微服务
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
)
|
||||
|
||||
type Favorites struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (Favorites) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int64("id").Unique().Immutable(),
|
||||
field.Int64("user_id"),
|
||||
field.String("target_type").MaxLen(20),
|
||||
field.Int64("target_id"),
|
||||
field.Time("created_at").Default(time.Now).Immutable(),
|
||||
}
|
||||
}
|
||||
|
||||
func (Favorites) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("user_id", "target_type", "target_id").Unique(),
|
||||
index.Fields("user_id", "created_at"),
|
||||
index.Fields("target_type", "target_id"),
|
||||
index.Fields("user_id", "target_type", "created_at"),
|
||||
}
|
||||
}
|
||||
|
||||
func (Favorites) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user