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" ) // Api holds the schema definition for the Api entity. type Api struct { ent.Schema } func (Api) Annotations() []schema.Annotation { return []schema.Annotation{ entsql.Annotation{Table: "api"}, entsql.WithComments(true), } } // Fields of the Api. func (Api) Fields() []ent.Field { return []ent.Field{ field.Int("id").Positive(), field.String("path").MaxLen(100).NotEmpty().Comment("api路径"), field.String("method").MaxLen(20).NotEmpty().Comment("api请求方法"), field.String("description").MaxLen(60).Optional().Comment("api描述"), field.Time("createdAt").Default(time.Now).Immutable().Comment("创建时间"), // 创建时间 } } // Edges of the Api. func (Api) Edges() []ent.Edge { return []ent.Edge{ edge.From("permissions", Permission.Type).Ref("apis"), } }