mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-02 14:53:55 +08:00
40 lines
732 B
Go
40 lines
732 B
Go
package schema
|
|
|
|
import (
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/entsql"
|
|
"entgo.io/ent/schema"
|
|
"entgo.io/ent/schema/edge"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// Role holds the schema definition for the Role entity.
|
|
type Role struct {
|
|
ent.Schema
|
|
}
|
|
|
|
func (Role) Annotations() []schema.Annotation {
|
|
return []schema.Annotation{
|
|
entsql.Annotation{Table: "roles"},
|
|
}
|
|
}
|
|
|
|
// Fields of the Role.
|
|
func (Role) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.Int64("id"),
|
|
field.String("name"),
|
|
field.Text("description"),
|
|
field.Time("created_at").Default(time.Now),
|
|
}
|
|
}
|
|
|
|
// Edges of the Role.
|
|
func (Role) Edges() []ent.Edge {
|
|
return []ent.Edge{
|
|
edge.To("admins", Admin.Type).Through("admin_roles", AdminRole.Type),
|
|
}
|
|
}
|