chore: 初始化 Cloudreve 源码仓库

This commit is contained in:
2026-09-13 11:28:59 +08:00
commit 2a7b03ab1d
489 changed files with 163867 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"github.com/cloudreve/Cloudreve/v4/inventory/types"
)
// Share holds the schema definition for the Share entity.
type Share struct {
ent.Schema
}
// Fields of the Share.
func (Share) Fields() []ent.Field {
return []ent.Field{
field.String("password").
Optional(),
field.Int("views").
Default(0),
field.Int("downloads").
Default(0),
field.Time("expires").
Nillable().
Optional().
SchemaType(map[string]string{
dialect.MySQL: "datetime",
}),
field.Int("remain_downloads").
Nillable().
Optional(),
field.JSON("props", &types.ShareProps{}).Optional(),
}
}
// Edges of the Share.
func (Share) Edges() []ent.Edge {
return []ent.Edge{
edge.From("user", User.Type).
Ref("shares").Unique(),
edge.From("file", File.Type).
Ref("shares").Unique(),
}
}
func (Share) Mixin() []ent.Mixin {
return []ent.Mixin{
CommonMixin{},
}
}