This commit is contained in:
2025-07-19 02:03:24 +08:00
commit ac6eeff8c9
44 changed files with 10305 additions and 0 deletions

View File

@ -0,0 +1,34 @@
package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"time"
)
// CloudflareAccounts holds the schema definition for the CloudflareAccounts entity.
type CloudflareAccounts struct {
ent.Schema
}
// Fields of the CloudflareAccounts.
func (CloudflareAccounts) Fields() []ent.Field {
return []ent.Field{
field.String("name").NotEmpty().Comment("账户名称"),
field.String("account_id").NotEmpty().Comment("Cloudflare Account ID"),
field.Text("api_token").Sensitive().Comment("Cloudflare API Token"),
field.String("email").Optional().Comment("Cloudflare 邮箱(可选)"),
field.Int8("status").Default(1).Comment("状态 1=启用, 0=禁用"),
field.Text("remark").Optional().Comment("备注"),
field.Time("created_at").Default(time.Now).Immutable(),
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now),
}
}
// Edges of the CloudflareAccounts.
func (CloudflareAccounts) Edges() []ent.Edge {
return []ent.Edge{
edge.To("cloudflare_buckets", CloudflareR2.Type),
}
}

View File

@ -0,0 +1,62 @@
package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"time"
)
// CloudflareR2 holds the schema definition for the CloudflareR2 entity.
type CloudflareR2 struct {
ent.Schema
}
// Fields of the CloudflareR2.
func (CloudflareR2) Fields() []ent.Field {
return []ent.Field{
field.String("owner_id").Comment("业务归属标识"),
field.String("name").
NotEmpty().
Comment("桶名称(唯一)"),
field.String("location").
NotEmpty().
Comment("桶区域,如 apac、eea、us"),
field.String("storage_class").
NotEmpty().
Comment("存储类型,如 standard、infrequent-access"),
field.Int8("status").
Default(1).
Comment("状态1=启用0=禁用"),
field.Int64("payload_size").
Default(0).
Comment("对象数据体积payloadSize单位字节"),
field.Int64("metadata_size").
Default(0).
Comment("对象元数据大小metadataSize单位字节"),
field.Int("object_count").
Default(0).
Comment("存储桶内对象总数"),
field.Text("remark").
Optional().
Comment("备注"),
field.Time("created_at").
Default(time.Now).
Immutable(),
field.Time("updated_at").
Default(time.Now).
UpdateDefault(time.Now),
}
}
// Edges of the CloudflareR2.
func (CloudflareR2) Edges() []ent.Edge {
return []ent.Edge{
edge.From("cloudflare_account", CloudflareAccounts.Type).
Ref("cloudflare_buckets").
Unique().
Required().
Comment("所属 Cloudflare 账户"),
}
}