🚧 Refactor basic services

This commit is contained in:
2025-12-14 02:19:50 +08:00
parent d16905c0a3
commit cc4c2189dc
126 changed files with 18164 additions and 4247 deletions

View File

@@ -0,0 +1,65 @@
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"
"voidraft/internal/models/schema/mixin"
)
// Document holds the schema definition for the Document entity.
type Document struct {
ent.Schema
}
// Annotations of the Document.
func (Document) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "documents"},
}
}
// Mixin of the Document.
func (Document) Mixin() []ent.Mixin {
return []ent.Mixin{
mixin.TimeMixin{},
mixin.SoftDeleteMixin{},
}
}
// Fields of the Document.
func (Document) Fields() []ent.Field {
return []ent.Field{
field.String("title").
MaxLen(255).
NotEmpty().
StructTag(`json:"title"`).
Comment("document title"),
field.Text("content").
Optional().
Default("\n∞∞∞text-a\n").
StructTag(`json:"content"`).
Comment("document content"),
field.Bool("locked").
Default(false).
StructTag(`json:"locked"`).
Comment("document locked status"),
}
}
// Edges of the Document.
func (Document) Edges() []ent.Edge {
return nil
}
// Indexes of the Document.
func (Document) Indexes() []ent.Index {
return []ent.Index{
index.Fields("title"),
index.Fields("created_at"),
index.Fields("updated_at"),
}
}