Init V4 community edition (#2265)
* Init V4 community edition * Init V4 community edition
This commit is contained in:
59
ent/schema/policy.go
Normal file
59
ent/schema/policy.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/cloudreve/Cloudreve/v4/inventory/types"
|
||||
)
|
||||
|
||||
// StoragePolicy holds the schema definition for the storage policy entity.
|
||||
type StoragePolicy struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (StoragePolicy) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("name"),
|
||||
field.String("type"),
|
||||
field.String("server").
|
||||
Optional(),
|
||||
field.String("bucket_name").
|
||||
Optional(),
|
||||
field.Bool("is_private").
|
||||
Optional(),
|
||||
field.Text("access_key").
|
||||
Optional(),
|
||||
field.Text("secret_key").
|
||||
Optional(),
|
||||
field.Int64("max_size").
|
||||
Optional(),
|
||||
field.String("dir_name_rule").
|
||||
Optional(),
|
||||
field.String("file_name_rule").
|
||||
Optional(),
|
||||
field.JSON("settings", &types.PolicySetting{}).
|
||||
Default(&types.PolicySetting{}).
|
||||
Optional(),
|
||||
field.Int("node_id").Optional(),
|
||||
}
|
||||
}
|
||||
|
||||
func (StoragePolicy) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
CommonMixin{},
|
||||
}
|
||||
}
|
||||
|
||||
func (StoragePolicy) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.To("users", User.Type),
|
||||
edge.To("groups", Group.Type),
|
||||
edge.To("files", File.Type),
|
||||
edge.To("entities", Entity.Type),
|
||||
edge.From("node", Node.Type).
|
||||
Ref("storage_policy").
|
||||
Field("node_id").
|
||||
Unique(),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user