Files
unR2/internal/ent/schema/cloudflarer2.go
2025-07-19 02:03:24 +08:00

63 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 账户"),
}
}