Files
likedream/internal/ent/schema/cpimage.go
T
2025-11-06 16:27:41 +08:00

52 lines
1.0 KiB
Go

package schema
import (
"likedream-goframe/internal/ent/schema/mix"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
)
// CpImage holds the schema definition for the CpImage entity.
type CpImage struct {
ent.Schema
}
// Fields of the CpImage.
func (CpImage) Fields() []ent.Field {
return []ent.Field{
field.UUID("image_id", uuid.New()).Default(uuid.New).Unique().Immutable(),
field.String("key").NotEmpty(),
field.Int64("user_id").Positive(),
field.String("content_type").NotEmpty(),
field.Int64("content_length").Positive(),
}
}
// Edges of the CpImage.
func (CpImage) Edges() []ent.Edge {
return []ent.Edge{
edge.From("user", SysUser.Type).
Ref("images").
Field("user_id").
Unique().
Required(),
}
}
func (CpImage) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "cp_image"},
}
}
func (CpImage) Mixin() []ent.Mixin {
return []ent.Mixin{
mix.MixinTime{},
}
}