初始化

This commit is contained in:
SunYF
2026-08-28 14:07:22 +08:00
parent a185247ab1
commit b34325a16f
971 changed files with 291 additions and 220360 deletions
-49
View File
@@ -1,49 +0,0 @@
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"
)
// Permission holds the schema definition for the Permission entity.
type Permission struct {
ent.Schema
}
func (Permission) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "permission"},
entsql.WithComments(true),
}
}
// Fields of the Permission.
func (Permission) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.String("name").MaxLen(20).NotEmpty().Comment("权限名称"),
field.String("code").MaxLen(40).NotEmpty().Comment("权限代码"),
field.Int("parentId").Optional().Nillable().Comment("父权限ID"),
field.String("sort").Default("0").Comment("排序号"),
field.Bool("isMenu").Default(false).Comment("是否菜单"),
field.String("description").MaxLen(60).Optional().Comment("权限描述"),
field.Time("createdAt").Default(time.Now).Immutable().Comment("创建时间"), // 创建时间
}
}
// Edges of the Permission.
func (Permission) Edges() []ent.Edge {
return []ent.Edge{
edge.From("roles", Role.Type).Ref("permissions"),
edge.To("apis", Api.Type),
edge.To("children", Permission.Type).
From("parent").
Field("parentId").
Unique(),
}
}