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

48 lines
1.0 KiB
Go

package schema
import (
"likedream-goframe/internal/ent/schema/mix"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"github.com/shopspring/decimal"
)
// SysAgent holds the schema definition for the SysAgent entity.
type SysAgent struct {
ent.Schema
}
// Fields of the SysAgent.
func (SysAgent) Fields() []ent.Field {
return []ent.Field{
field.Int("level"),
field.String("rate").GoType(decimal.Decimal{}).SchemaType(map[string]string{
dialect.MySQL: "decimal(10,2)",
dialect.Postgres: "numeric(10,2)",
}),
}
}
// Edges of the SysAgent.
func (SysAgent) Edges() []ent.Edge {
return []ent.Edge{
edge.From("users", SysUser.Type).Ref("agent").Unique().Annotations(entsql.OnDelete(entsql.Cascade)),
}
}
func (SysAgent) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "sys_agent"},
}
}
func (SysAgent) Mixin() []ent.Mixin {
return []ent.Mixin{
mix.MixinTime{},
}
}